sorry if the answer to this question is a bit obvious but:
Let’s say that I have a program that counts the clicks on a screen. To do this I use something like:
function setup() a = 0 end function touched(touch) if touch.state == BEGAN then a = a + 1 print(a) end end
Now let’s say that I have a menu for this application. This program, if you tap the top of the screen will go to menu, and if you tap the bottom will go to the program function:
function setup() a = 0 state = "menu" end function draw() if state == "menu" then domenu() end if state == "program" then doprogram() end end function doprogram() -- more code here if CurrentTouch.y > HEIGHT/2 then print("menu") state = "menu" end function touched(touch) if touch.state == BEGAN then a = a +1 print(a) end end end function domenu() --do any code here if CurrentTouch.y < HEIGHT/2 then state = "program" print("prog") end end
The first time you run it it works fine, however, if you go from the function doprogram() back to domenu(), then it will still count the taps on the menu screen, even when not specified. Is there any way to stop this? Thanks!