Advancing Animation Selectively

Game Editor comments and discussion.

Advancing Animation Selectively

Postby sirmatthew » Fri Jun 19, 2009 4:01 pm

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 1737 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!
sirmatthew
 
Posts: 8
Joined: Tue Jun 02, 2009 4:52 pm
Score: 0 Give a positive score

Re: Advancing Animation Selectively

Postby jimmynewguy » Fri Jun 19, 2009 4:12 pm

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;
}
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Advancing Animation Selectively

Postby Kalladdolf » Fri Jun 19, 2009 4:14 pm

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 :)
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Advancing Animation Selectively

Postby sirmatthew » Fri Jun 19, 2009 4:26 pm

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!!
sirmatthew
 
Posts: 8
Joined: Tue Jun 02, 2009 4:52 pm
Score: 0 Give a positive score

Re: Advancing Animation Selectively

Postby jimmynewguy » Fri Jun 19, 2009 4:30 pm

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
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Advancing Animation Selectively

Postby Kalladdolf » Fri Jun 19, 2009 4:54 pm

Sometimes it's hard to say which takes more writing effort, switch() or if().
About the same, I guess.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron