4E4 Update

Published July 01, 2005
Advertisement
I've been playing around with animations. I'm hitting a sticking point that causes the first frame to be played until a key is released, this is due to the game saying "You've pressed 'a', I'll play the associated animation". Obviously I need a way to check if it's already running first.

I'm going to draw up a class diagram for my game, as the system is getting pretty complex, what with all the interfaces and callbacks, etc.
Previous Entry 4E4 Update
Next Entry New flat
0 likes 6 comments

Comments

jollyjeffers
Quote:Obviously I need a way to check if it's already running first.

A simple boolean flag would probably suffice...?

bool animation_playing = false;

onKeyDown( ) : animation_playing = true;
onKeyUp( ) : animation_playing = false;
onFrameRender( ) : if( animation_playing ) { ... }

That way, multiple key downs wouldn't actually change the state unless there had been a matching key-up in between [smile]

Quote:I'm going to draw up a class diagram for my game

<rant>
WHATEVER you do - do not waste your time with Rational Rose. I know I said that I got it for free at work, but it's gotta be one of the most piss-awful pieces of crap to carry a price tag this century.

Yes, I don't know how to use it, yes, I'm using the 2002 version... but first impressions are everything. Rational-Rose-Rating-- [razz]
</rant>

Jack
July 01, 2005 05:01 AM
evolutional
LOL @ Rational rose rant

Yeah, I have a boolean flag for that, but it's not working. I think I have to ensure the animation is being started in one place only.
July 01, 2005 08:14 AM
Patbert
It's true, Rational Rose has more bugs than you can shake a stick at. The only good thing about it is it can make class diagrams from imported C++ code. I've heard Visio is a decent modeller though.
July 01, 2005 09:18 AM
jollyjeffers
Quote:It's true, Rational Rose has more bugs than you can shake a stick at.

I'm not sure I've found any *bugs* as such, just the general program is clunky, ugly and i dunno - just one that gives me a headache and puts me in a bad mood. Can't quite explain why that is.

Jack
July 01, 2005 03:19 PM
MrP
My SetAnimation function has two boolean parameters.
The first, reset, defaults to false and specifies whether or not the animation should be restarted if the animation being set is already the current animation.

The second parameter, conditional, also defaults to false and is passed to the reset function being called on the current animation (again, only if the animation being set is already the current animation).
If the animation was set as repeating when it was created this parameter does nothing and the animation will be restarted. However if the animation was not set as repeating this parameter specifies whether or not the animation will restart when the animation is finished (when it reaches the last frame).

This yields the following results:


For an animation created as repeating:
m_sprite.SetAnimation("run"); 
The animation will not be restarted, it will continue to run.

m_sprite.SetAnimation("run", true);
The animation will be restarted.


For an animation not created as repeating:
m_sprite.SetAnimation("run", true);
The animation will not be restarted, it will stop after playing one time.

m_sprite.SetAnimation("run", true, true);
The animation will be restarted.


Anyway, the point of all that was that with my system if you are setting an animation when a key is pressed, as long as you call the SetAnimation function with the correct parameters the animation will run correctly even while the key is held down.
July 01, 2005 05:15 PM
boolean
Someone called?
July 02, 2005 09:41 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement