Rss

Scene Timer Events

Timer Events.

Having an event occur in ISE involves using a Scene’s Timer function. Let’s say you want something to occur after 1.5 seconds in a scene called myScene. There’s a quick n dirty way to do it using a null Lambda expression:

myScene.Timer(1.5f, () => {
// Put code here
});

This code will then run after 1.5 seconds. The time the event will fire will be a minimum of 1.5 seconds, it depends on the frame rate, and will not be precisely 1.5 seconds, but it will be imperceptibly close.

For a more traditional timer event, there are other Timer overloads, see the Timer function for additional details.

Deleting a timer event.

Regardless of the Timer overload used, the timer function returns a variable of class descended from AbstractSceneTimerEventInfo. This variable is internally and automatically added to the Scene, so to stop the timer event from firing, remove it from the scene:

// Create the Timer event

AbstractSceneTimerEventInfo info = myScene.Timer(1.5f, () => {  } );

// Remove the Timer event

myScene.Remove(info);