How can I make my lamp indicator color turn green once it reaches a certain number with the app.label.Text
    3 views (last 30 days)
  
       Show older comments
    
I'm making an app thats whack a mole, and for my app i want to do different levels, with each level the objects move faster. I'm trying to make it where in each level theres a lamp indicator that turns green after a certain amount of points is aquired. I'm using buttons for my objects moving, Label text as where the points get shown growing, but everytime I make a loop or some formof code with the lamp, it'll just stay red.
I tried using 
if app.Label.Text<500
    app.Lamp.Color='r'
else 
    app.Lamp.Color='g'
end
and it stays red because I thin once you start the game it just recognizes the app.Label.Text already under 500 and keeps it red after 500.
1 Comment
  VBBV
      
      
 on 25 Apr 2023
				
      Edited: VBBV
      
      
 on 25 Apr 2023
  
			Note that if-else  is a conditional  statement not a loop.  it will execute only ONCE if the condition is NOT present inside any loop (e.g. while or for).  So once the condition is executed, it will never change the values of variables again unless present inside the loop. From your code its apparent that the condition  is NOT INSIDE any loop. Try with a loop instead. 
Answers (1)
  chicken vector
      
 on 25 Apr 2023
        uilabel dont allow much interactivity.
I guess you have some familiarity with Callbacks, so I suggest you to use uieditfield and have a look at:
@EditFieldValueChanging
This callbacks triggers a function every time the text inside the EditField is changed.
Then you can insert your length check inside that.
0 Comments
See Also
Categories
				Find more on Environment and Settings in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

