playMaker

Author Topic: Time out function?  (Read 2948 times)

m1

  • Playmaker Newbie
  • *
  • Posts: 11
Time out function?
« on: September 12, 2011, 03:40:20 PM »
Hi, perhaps I'm missing something really basic here, but I'm trying to create a simple menu system with a time out function and having difficulty.  It's the simple things that are the worst time suckers.  I have 1 button on the screen for user input.  If it isn't hit within 30 seconds, the scene should reload.  Any ideas of the best method to create a timer to control this? 

Thanks!!
Brian

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Time out function?
« Reply #1 on: September 13, 2011, 01:36:06 AM »
Hi,

 one simple way is to create a fsm with a state featuring a send even with a delay that triggers another state where nothing happens.

https://hutonggames.fogbugz.com/default.asp?W34

 so you have a "START TIMEOUT" for a state with a send event set to trigger a "TIME OUT" event. From that event you can then react in your various fsm to do something. As soon as you need a timeout again, simply call "START TIMEOUT" event again.

 You could also make it quite flexible by passing the delay amount in the "START TIMEOUT" so that the caller can define.

 of course, this way would not concurrent timeouts ( if you use this globally). You can always implement a similar system per state as well making it totally local and trigger a transition instead of a global event.

Bye,

 Jean

m1

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Time out function?
« Reply #2 on: September 13, 2011, 04:31:06 PM »
Thanks!  That worked for my purpose. 
Brian