how to start an event if application is idle for sometime

If the screen is not touched for 5 seconds, I want a fly to enter the screen from above, fly around a bit and then a frog eats it.

Plus, if the screen is touched after the fly enters the screen, i want the fly to move out immediately.

How can i do this? [import]uid: 175611 topic_id: 31531 reply_id: 331531[/import]

Hi,
You’ll need to use a screen touch method (to sense if/when the screen is touched) and a timer to control the fly’s appearance.

Basically this:

  1. start a timer of 5000 milliseconds
  2. if the screen is touched during this delay, cancel the timer (or reset it to 5000)
  3. if the screen is NOT touched, timer completes and fly is spawned
  4. while fly is on screen, if screen is touched, fly exits the screen

Boolean variables controls the “state” of the fly and the timer, and you check/set these variables as necessary.

Brent [import]uid: 9747 topic_id: 31531 reply_id: 126003[/import]

ok, I understand that. but how am i supposed to start a timer inside a function?

I was thinking of using “timer.performWithDelay”…

and how can i detect screen touch? [import]uid: 175611 topic_id: 31531 reply_id: 126091[/import]

Hi,
You’ll need to use a screen touch method (to sense if/when the screen is touched) and a timer to control the fly’s appearance.

Basically this:

  1. start a timer of 5000 milliseconds
  2. if the screen is touched during this delay, cancel the timer (or reset it to 5000)
  3. if the screen is NOT touched, timer completes and fly is spawned
  4. while fly is on screen, if screen is touched, fly exits the screen

Boolean variables controls the “state” of the fly and the timer, and you check/set these variables as necessary.

Brent [import]uid: 9747 topic_id: 31531 reply_id: 126003[/import]

ok, I understand that. but how am i supposed to start a timer inside a function?

I was thinking of using “timer.performWithDelay”…

and how can i detect screen touch? [import]uid: 175611 topic_id: 31531 reply_id: 126091[/import]