• entries
145
222
• views
138593

23 views

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...object.Animations["YourAnimation"].Tracks.Create(....);

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.Create("MoveTrack");            _cursor.Animations["TestAnimation"].Tracks["MoveTrack"].Keys.Create(0.0f);            _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.Create(2950.0f);            _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.Create(7000.0f);            _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.Create(30000.0f);            _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.

There are no comments to display.

## Create an account

Register a new account