Timer component strange reset behaviour
Posted: Tue Mar 12, 2019 8:20 am
Hi,
I'm having a proglem with the Timer component. Is it normal that the Timer.RepeatCount stays the same between AppStates, but in fact, it isn't... ?
I made a quick example to show you my problem. The trace shows that the TimerCube and TimerBlue stays the same, but they are only working once. Aren't they supposed to reset between states so they can continue to work as expected? I think this is really weird...
I'm having a proglem with the Timer component. Is it normal that the Timer.RepeatCount stays the same between AppStates, but in fact, it isn't... ?
I made a quick example to show you my problem. The trace shows that the TimerCube and TimerBlue stays the same, but they are only working once. Aren't they supposed to reset between states so they can continue to work as expected? I think this is really weird...
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" ClearColor="0 0 0.3 0" FileVersion="2">
<OnLoaded>
<SetAppState State="AppState1"/>
</OnLoaded>
<States>
<AppState Name="AppState1">
<OnStart>
<ZExpression>
<Expression>
<![CDATA[App.ClearColor.R = 0.3;
App.ClearColor.G = 0.0;
App.ClearColor.B = 0.0;
trace(intToStr(TimerCube.RepeatCount));]]>
</Expression>
</ZExpression>
</OnStart>
<OnUpdate>
<Timer Name="TimerCube" Interval="1" RepeatCount="2">
<OnTimer>
<SpawnModel Model="Model1"/>
</OnTimer>
</Timer>
<Timer Interval="4">
<OnTimer>
<SetAppState State="AppState2"/>
</OnTimer>
</Timer>
</OnUpdate>
</AppState>
<AppState Name="AppState2">
<OnStart>
<ZExpression>
<Expression>
<![CDATA[App.ClearColor.R = 0.0;
App.ClearColor.G = 0.0;
App.ClearColor.B = 0.3;
trace(intToStr(TimerBlue.RepeatCount));]]>
</Expression>
</ZExpression>
</OnStart>
<OnUpdate>
<Timer Name="TimerBlue" Interval="1" RepeatCount="0">
<OnTimer>
<SetAppState State="AppState1"/>
</OnTimer>
</Timer>
</OnUpdate>
</AppState>
</States>
<Content>
<Mesh Name="Mesh1">
<Producers>
<MeshBox Scale="0.2 0.2 0.2"/>
</Producers>
</Mesh>
<Model Name="Model1">
<OnSpawn>
<ZExpression>
<Expression>
<![CDATA[CurrentModel.Position.X = random(0,5);
CurrentModel.Position.Y = random(0,5);
CurrentModel.Position.Z = random(-5,5);
CurrentModel.Rotation = rnd();]]>
</Expression>
</ZExpression>
</OnSpawn>
<OnUpdate>
<Timer/>
</OnUpdate>
<OnRender>
<RenderMesh Mesh="Mesh1"/>
</OnRender>
</Model>
</Content>
</ZApplication>