I'd like to add my app two buttons (Up, Down) in order to set the value of a variable x . The behavior should be:
1. while Up is TouchDown, increment x by 1 (x++) every 500ms
2. while Down is TouchDown, decrement x by 1 (x- -) every 500ms
I'm a beginner at App Inventor, and have no idea about what structure is needed in order to realize this apparently simple behave... Can somebody kindly give me some hints?
--
thank you for this complete configuration! I tried, and works perfecly :) I have just one question: why do you enable the Timer of Clock1 only when a button is pressed? It seems more simple leaving the Timer always enabled and, when buttons TouchUp, set Button_pressed to " ". Sorry if my names are different from yours!
--
Well, it's just the way it came to my mind at the time. Your idea is really good.
Usually I leave only the processes that are essential for the app to run and turn off whatever is not necessary.
In this case, it's OK to leave the clock running, but if you have an app with a lot of things moving at the same time, it's better to keep the amount of processes running to the minimum. Especially in App Inventor 2.
--
Another thing that just came to my mind. With my method, the amount of time since you press the button until the global is increased or decreased is the same, but if you leave the timer running, you never get the same time.
--
thank you for your replies Italo; your considerations and suggestions are very usefull for my app, expecially the one about saving computational resources.
--
댓글 없음:
댓글 쓰기