Page 1 of 1

stopping an animation loop

Posted: Sun Jan 23, 2005 2:19 am
by databandit
hi,
how is it possible to stop an animation after it has played once?

-zubair-

Posted: Sun Jan 23, 2005 2:33 am
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

Posted: Sun Jan 23, 2005 2:35 am
by databandit
there's nothing similar to your animationframe < blabla . . . .

Posted: Sun Jan 23, 2005 8:21 am
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.