Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Extending Gosu / [Gosu C++] Animation class
- By TheOm3ga Date 2010-05-16 02:20
I've been using an Animation class for my project that features dynamic movement with different types of easing. It's based on Robert Penner's easing equations [], which have been broadly used for Flash development, and I think they work really well for games.

The way it works is very simple. You create an animation object, choosing the initial and final values, duration, type and initial delay of the animation. Then, in every iteration you call the update() method to update the position of the animation one frame at a time. You can retrieve the current position using getX and getY methods.

There are 8 types of animation so far:
    enum tipoAnim {tEaseInQuad, tEaseOutQuad, tEaseInOutQuad,
       tEaseInCubic, tEaseOutCubic, tEaseInOutCubic,
       tEaseInQuart, tEaseOutQuart, tEaseInOutQuart,
       tEaseOutBack, tLinear};

boost::scoped_ptr<Animacion> myAnim (new Animacion(initialX, initialY, finalX, finalY, duration, Animation::tipoAnim, delay));
myAnim -> update();
myImage -> draw(myAnim -> getX(), myAnim -> getY(), 1);

Source file:
Header file:

Hope you find it useful!
Up Topic Gosu / Extending Gosu / [Gosu C++] Animation class

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill