• entries
    437
  • comments
    1000
  • views
    335623

4E4 Update

Sign in to follow this  
evolutional

113 views

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.
Sign in to follow this  


6 Comments


Recommended Comments

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

Share this comment


Link to comment
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.

Share this comment


Link to comment
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.

Share this comment


Link to comment
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

Share this comment


Link to comment
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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now