android
  #1  
Old 03-30-2010, 11:04 AM
lsquish's Avatar
lsquish lsquish is offline
Junior Member
 
Join Date: Mar 2010
Posts: 47
Default Need help with annoying glitch

well, i'm making a game, and you can quit by pressing the home button, the problem is when you press the home button twice quits and the next time the you go onto it it also quits and then you muts try again.

i think it must be that the button pressed is still in the queue and it reads it as soon as you start playing, if it is then then how do you clear queue of messages, or is there another reason for the glitch.
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 03-30-2010, 04:24 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

I also noticed that on the simulator, but I don't think this is a real problem on the player.
Anyway, clearing the queue of messages seems to be a hard thing to do properly. Tetrajak is also searching for a good way to do it.

In the meantime, I found that this works: (I got this from Cilmaviel's Paint)
Code:
for i=0, 1000 do --(1000 may be a little much, how much input do you expect? 2 or 10 will also work)
control.read()
end
although this is just a harsh method and might clear any input that the app does need, it works when you put it at the right place.
Reply With Quote

  #3  
Old 03-30-2010, 04:44 PM
bicycle4fun bicycle4fun is offline
Junior Member
 
Join Date: Jan 2010
Posts: 11
Default

I think that this "glitch" is the reason why this is in the FAQ:

Q. My application works in the simulator, but not on the player, why?

A.
If you are using control.read() in your application you must have (at least) an os.wait(40) or os.sleep(4) in an else statement. You can go without os.wait() or os.sleep() if you use control.read(1) instead. Got another cause for this? Why not let the FAQ know in a reply on this thread?

I believe what this is telling you (and Brett_val's reply does using brute force at the code level), is there needs to be a minimum 40 millisecond delay to clear the buffer. Until I saw this, I observed this "glitch" behavior in both the simulator and on the player.
Reply With Quote

  #4  
Old 03-31-2010, 08:37 AM
lsquish's Avatar
lsquish lsquish is offline
Junior Member
 
Join Date: Mar 2010
Posts: 47
Default

Thanks Brett Val, your solution worked a treat.
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:00 AM.