Game Development Community

Doing Animation when a level ends

by ToaTerra · in Game Design and Creative Issues · 09/26/2009 (7:31 pm) · 3 replies

Hi: I would like to have some of my scene objects perform an animation (for example, a little dance) when the scence has ended. To do this I probably need to intercept the onLevelEnded event, start the animation, delay a bit, then cause the onLevelEnded event to occur. Does anyone have code or know of a tutorial/forum post that explains how to do this? Thanks in advance.

#1
09/27/2009 (11:19 am)
I think you're right about intercepting onLevelEnd and pausing the actual end. You also need some way to find all the objects that need to play this animation. I'd suggest creating a global SimSet and adding all the objects to it that you want to do this behaviour. Then when the level ends, iterate through the group and play the animation on all the objects you find.
#2
09/27/2009 (11:24 am)
You could also have whatever ends the level trigger the animation instead, and the animation trigger the actual end.
#3
10/11/2009 (5:22 pm)
Ronny is correct. You wouldn't intercept the onLevelEnd() function. Think of it as technically the level is not ending until after the user sees their score or the dance animation completes. Some rough pseudo-code may be:

-Run endingDance() function when player steps next to exit door
-endingDance() plays character dance animation then sets a countdown timer (danceTimer) for 3 seconds.
-When danceTimer expires, call onLevelEnd()