Hello,
So far I have been able to solve most of my issues by lurking. I'm developing a game for the iPad and i have some troubles with timers.
The simple task I intend to solve with timers is the following:
My characters talk with each other. I set a text. Wait... I remove the text.
I already implemented a state machine to allow for complex conversations.Mostly by switch and some helpful functions.
My problem is with the wait part.
First approach was to create a timer 3000ms and once it timed out start the next iteration of th state machine. Destroying the timer and create a new one as needed. Didn't work because once a timer is created it seems to exist forever. Destroy timer seemed to do nothing. Creating a new timer seemed to only work if the timer has a new unique name.
The next approach was to create a periodic timer at startup and use it as clock. Whenever I need to wait I set a real value to the desired time. This value is decreased in the "clock timer" and once it reaches 0 it fires up the state engine again. This last approach works great.
However, once on the iPad the last approach results in frequent crashes. So far it seems that the problem appears when I try to set a new timer value at the same time I change the timer value in the clock timer. So... A classic multithread problem.
Before I include a semaphore in my script I pose a few questions:
Is there a reliable way to stop and restart a timer and to change the time on the timer?
Are there known bugs that lead to crashes on the iPad ?
Is my assessment of the issue realistic or am I on the wrong track?
What is the save minimum time a timer should have? 500ms? 100ms?