Jump to content


Sign in to follow this  
  • entries
  • comments
  • views

Animating the dead

Sign in to follow this  


Believe it or not, that arrow is animated. "So?" you say. Well, says I, it's part of my new animation object which utilizes time based animation so all you need to do is set a point and it'll tween the frames. What's more, it also handles linear and spline interpolation (and even just snapping to points). It uses the standard keyframes, but not only the usual position, scale and rotation keyframes. When it's done you'll be able to define your own keyframe types and there'll be other types of key frames built in to allow users to modify a number of aspects of the sprites over a time period. How? I'm glad you didn't ask:

// Define a keyframe by inheriting from the base keyframe:
public MyKey
: Key
// Your properties go here...
public SomeType MyCustomProperty
// Yada, yada...

public override Apply(int frameIndex, Key previousFrame, Key nextFrame)
// Do your interpolation here.

protected internal void UpdateLayerObject(ILayerObjectTransformable layerObject)
// Apply to sprites or whatever here.

// ... meanwhile in your initialization code or whatever...

That's a rough idea of how I've planned it out, it needs refinement, but I think this should allow for a fairly flexible animation system.

The code to setup an animation is fairly straightforward (well, I think it is...):

_cursor.Animations.Create("TestAnimation", 30000.0f);
_cursor.Animations["TestAnimation"].Looped = true;
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[0].Position = new Vector2D(320, 240);
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[0].InterpolationMode = InterpolationMode.Spline;
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[1].Position = new Vector2D(0, 0);
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[1].Rotation = -172.0f;
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[1].InterpolationMode = InterpolationMode.Spline;
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[2].Position = new Vector2D(240, 320);
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[2].Scale = new Vector2D(6.0f, 6.0f);
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[2].Rotation = 894.52f;
_cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys[3].Position = new Vector2D(320, 240);

That's the code to produce the animation for the cursor, sure, it's not pretty, but that's how you do it.
Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!