stopping an animation loop

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
databandit
Posts: 32
Joined: Tue Dec 21, 2004 11:36 am

stopping an animation loop

Post by databandit »

hi,
how is it possible to stop an animation after it has played once?

-zubair-
Guest

Post by Guest »

Code: Select all

int x = 0;
while(x<1)
{
while(animationframe < blabla)
{
// do animation
}
x = 1;
}

do you get what i mean? :) i guess this should work
databandit
Posts: 32
Joined: Tue Dec 21, 2004 11:36 am

Post by databandit »

there's nothing similar to your animationframe < blabla . . . .
brcolow
Posts: 56
Joined: Mon Jul 19, 2004 6:15 am
Location: Arizona

Post by brcolow »

What he means is, create a while loop that checks what the current frame of the animation is and if it is greater than the last frame, it will stop animating, hence, playing once. Now my suggestion is to do this:

Code: Select all

IAnimatedMeshSceneNode* mesh;

for (int i = 0; mesh->getFrameNr() < mesh->getFrameCount(); i++)
{
mesh->setCurrentFrame(i);
}
What that does is, checks to see what the current frame number is and if it is less than the total frame count of the animation, add 1 to i, and set the current frame of the animation 1 more than the previous time. Now, the problem with this would be the FPS could be sparatic, because it depends on the speed of the for loop so I would suggest adding a system::pause or another for loop inside there checking the current time, to see if x amount has passed to keep a constant FPS in the animation.
G'Day.
Post Reply