Page 1 of 1

Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:01 pm
by sirmatthew
Hello all--

I've got an animation question which is perplexing me and hoping someone can resolve it.

For this example I created the following PNG graphic.

testPNGfile.PNG
testPNGfile.PNG (1.15 KiB) Viewed 1735 times


After creating a new actor I added this image as a single file to the animation and set the verticle frame count to 5 and a frame rate of 1. Presently, it will slowly scroll through each of the 5 images as if they were 5 different graphics and repeat the cycle when it reaches the fifth graphic. Sounds good so far.

What I would like to do is freeze the animation at the start of the game, but changing the frame rate to 0 is not allowed. Once the animation has stopped I would like to right-click on it and activate the animation, but only to advance it by 1 to display the very next graphic in the set of 5. If I right-clicked it again it would animate just enough to display the third graphic in the series of five.

Using counters to record and reset the number of right-mouse clicks I could assign and advance a variable number so the game knows exactly which image is being displayed at all times and would know exactly what to do if it is left-clicked (New, Load, Save, Delete, Exit).

Is this kind of animation scripting possible? How would I go about configuring it?

I realize I could create 5 actors with different graphics and overlay them to accomplish this same goal, but that would require so much more work, especially if I intended to create a duplicate set of different colored graphics to be used for rollover button effects.

Thanks!

Re: Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:12 pm
by jimmynewguy
to stop it use Create actor ->
Code: Select all
ChangeAnimationDirection("Event Actor", STOPPED);

then on mouse button down right ->
Code: Select all
animpos ++;
if(animpos == 5)
{
animpos = 0;
}

Re: Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:14 pm
by Kalladdolf
The first step is simple:
Go on "Create Actor" and then on "ChangeAnimationDirection" and select "STOPPED".
Then on right-click, go on script Editor:
Code: Select all
animpos += 1; if(animpos >= 4) {animpos = 0;} //This will make it go to the next frame and change back to 0 when it's reached the limit.

And then on leftclick:
Code: Select all
if(animpos == 0)
{//whatever}
if(animpos == 1)
{//you get the picture}
//etc


EDIT: Crap! Jimmy beat me to it! Nice job, man :)

Re: Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:26 pm
by sirmatthew
Yes! This is exactly what I was looking for! I saw that animpos but couldn't quite understand it enough to get it to work right. This will make things SOOO much easier. Thanks!!

Re: Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:30 pm
by jimmynewguy
well instead of doing a bunch of if's you could use switch() the only problem would be that animpos isn't an integral, so all you'd have to do is...
Code: Select all
int i = animpos;
switch(i)
{
case 0://do some stuff
break;
case 1://do some more stuff
break;
//ect
}

0 would be new in your case since animations start on 0 instead of 1

Re: Advancing Animation Selectively

PostPosted: Fri Jun 19, 2009 4:54 pm
by Kalladdolf
Sometimes it's hard to say which takes more writing effort, switch() or if().
About the same, I guess.