Timer.CurrentRelativeTime doesn't reset to zero when the countdown hasn't been finished!
One need to manually set it to 0 before use for no bad surprises afterwards.
I made an example to illustrate this :
There are two AppState. Both have Timer that switch from one AppState to another every 5 seconds.
You can skip that timer by pressing left or right keys. The AppState backgrounds have two different colors that vary with their own Timer, so it's easy to see what's going on. You'll see that the Timer.CurrentRelativeTime continues where it was.
Is it a bug? Or is it normal? In this case, it should be explained in the help doc
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" ClearColor="1 0 0 0" FileVersion="2">
<OnLoaded>
<SetAppState State="AppState1"/>
</OnLoaded>
<States>
<AppState Name="AppState1">
<OnUpdate>
<Timer Name="Timer1" Comment="5 seconds" Interval="5">
<OnTimer>
<SetAppState State="AppState2"/>
</OnTimer>
</Timer>
<KeyPress Keys="<" CharCode="32">
<OnPressed>
<SetAppState State="AppState2"/>
</OnPressed>
</KeyPress>
<ZExpression Expression="App.ClearColor = vector3(1 - Timer1.CurrentRelativeTime / 5,0,0);"/>
</OnUpdate>
</AppState>
<AppState Name="AppState2">
<OnUpdate>
<Timer Name="Timer2" Comment="5 seconds" Interval="5">
<OnTimer>
<SetAppState State="AppState1"/>
</OnTimer>
</Timer>
<KeyPress Keys=">" CharCode="32">
<OnPressed>
<SetAppState State="AppState1"/>
</OnPressed>
</KeyPress>
<ZExpression Expression="App.ClearColor = vector3(0, 1 - Timer2.CurrentRelativeTime / 5,0);"/>
</OnUpdate>
</AppState>
</States>
</ZApplication>