How can I use a timer to run a function from my GUI continuously?

3 views (last 30 days)
I am creating a game that needs to continuously update visuals as things like player health and level changes. I currently have a manual refresh button that will run all the "refresh" code to do this. I would like to run a timer in the opening function that calls this refresh function every one second (fixedrate, period 1, etc.). I have gotten all sorts of different errors, and no online forum seems to fix the issue.
function TestMapGui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
%Opening Code
t = timer...
start(t)
function Refresh_Callback(hObject, eventdata, handles)
guidata(hObject);
%All of the refreshing code
Thank you for any and all help, I've spent hours now trying different handles and formats.
  1 Comment
Jan
Jan on 27 Nov 2018
Please post, what is hidden behind the "..." in t = timer.... If you get "all sorts of different errors", post one code and the occurring error message. With neither the code nor the error message, there is no chance to suggest an improvement. "trying different handles and formats" is not detailed enough to know, what you try to do.

Sign in to comment.

Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!