Adonthell 0.4
|
Class that handles animated elements, their update and their playback. More...
#include <animation.h>
Public Member Functions | |
animation () | |
Default constructor. | |
~animation () | |
Destructor. | |
void | clear () |
Clears an animation, that is put it back into the original (constructor) state. | |
animation & | operator= (const animation &src) |
Animation copy (similar to copy ()). | |
void | copy (const animation &src) |
Synonym of operator = to guarantee its access from Python. | |
Playback control methods. | |
void | play () |
Starts the playback of the animation. | |
void | stop () |
Stops the playback of the animation. | |
play_state | playstate () const |
Returns whether the animation is currently being played. | |
void | rewind () |
Rewinds the animation to it's beginning. | |
void | next_frame () |
Directly jumps to the next frame. | |
State updating Methods. | |
bool | update () |
Updates the animation state. | |
Drawing Methods. | |
void | draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const |
Draw the object on the screen. | |
Saving/Loading Methods. | |
| |
s_int8 | get (igzstream &file) |
Loads an animation from an opened file. | |
s_int8 | load (string fname) |
Loads an animation from it's filename. | |
s_int8 | put (ogzstream &file) const |
Saves an animation into an opened file, in game format, with alpha and mask values. | |
s_int8 | save (string fname) const |
Saves an animation into an file, in game format, with alpha and mask values. | |
Global animation properties Methods. | |
u_int16 | nbr_of_frames () const |
Returns the number of frames in this animation. | |
u_int16 | nbr_of_images () const |
Returns the number of images in this animation. | |
u_int16 | currentframe () const |
Returns the index of the currently displayed frame. | |
void | set_currentframe (u_int16 framenbr) |
Sets the current frame. | |
s_int16 | xoffset () const |
Returns the global X offset of the animation. | |
s_int16 | yoffset () const |
Returns the global Y offset of the animation. | |
void | set_offset (s_int16 x, s_int16 y) |
Set the global offsets of this animation. | |
Image and Animationframe control Methods. | |
animationframe * | get_frame (u_int16 nbr) |
Returns a pointer to a desired frame. | |
image * | get_image (u_int16 nbr) |
Returns a pointer to a desired image. | |
s_int8 | insert_image (const image *im, u_int16 pos) |
Inserts an image at a given position of the image array. | |
s_int8 | insert_frame (const animationframe af, u_int16 pos) |
Inserts a frame at a given position of the animationframe array. | |
s_int8 | delete_image (u_int16 pos) |
Removes an image at a given position. | |
s_int8 | delete_frame (u_int16 pos) |
Removes a frame at a given position. | |
Special FX methods. | |
void | zoom (u_int16 sx, u_int16 sy, const animation *src) |
Zooms an animation. | |
Friends | |
class | win_anim |
Class that handles animated elements, their update and their playback.
Most often, you will want your drawn objects to be animated. Then you'll probably want to use this class. An animation contains:
During playback, the animation look at the first animation_frame. Each animation_frame refers to an image of the animation, and give it special mask and alpha parameters, as well as a position offset. It also have a delay parameter, telling how many game cycles this frame should stay. Once the delay expired, the animation jumps to the next frame, which is pointed by the current frame. That way, you can easily performs loops or others effects. Each image, as well as each animation_frame, can be accessed individually, thought you'd better try to avoid as much as possible to mess with that.
Definition at line 308 of file animation.h.
animation::animation | ( | ) |
Default constructor.
Definition at line 97 of file animation.cc.
animation::~animation | ( | ) |
Destructor.
Definition at line 118 of file animation.cc.
void animation::clear | ( | ) |
Clears an animation, that is put it back into the original (constructor) state.
Definition at line 102 of file animation.cc.
void animation::play | ( | ) | [inline] |
Starts the playback of the animation.
Definition at line 344 of file animation.h.
void animation::stop | ( | ) | [inline] |
Stops the playback of the animation.
Definition at line 357 of file animation.h.
play_state animation::playstate | ( | ) | const [inline] |
Returns whether the animation is currently being played.
Definition at line 372 of file animation.h.
void animation::rewind | ( | ) | [inline] |
Rewinds the animation to it's beginning.
Definition at line 381 of file animation.h.
void animation::next_frame | ( | ) |
Directly jumps to the next frame.
Definition at line 140 of file animation.cc.
bool animation::update | ( | ) | [virtual] |
Updates the animation state.
Reimplemented from drawable.
Definition at line 124 of file animation.cc.
void animation::draw | ( | s_int16 | x, |
s_int16 | y, | ||
const drawing_area * | da_opt = NULL , |
||
surface * | target = NULL |
||
) | const [virtual] |
Draw the object on the screen.
x | X position where to draw. |
y | Y position where to draw. |
da_opt | optional drawing_area to use during the drawing operation. |
target | pointer to the surface where to draw the drawable. If NULL, draw on the screen. |
Implements drawable.
Definition at line 146 of file animation.cc.
s_int8 animation::get | ( | igzstream & | file | ) |
Loads an animation from an opened file.
file | the opened file from which to load. |
Definition at line 160 of file animation.cc.
s_int8 animation::load | ( | string | fname | ) |
Loads an animation from it's filename.
fname | the name of the file to load. |
Definition at line 205 of file animation.cc.
s_int8 animation::put | ( | ogzstream & | file | ) | const |
Saves an animation into an opened file, in game format, with alpha and mask values.
file | opened file where to save into. |
Definition at line 217 of file animation.cc.
s_int8 animation::save | ( | string | fname | ) | const |
Saves an animation into an file, in game format, with alpha and mask values.
fname | file name where to save into. |
Definition at line 249 of file animation.cc.
u_int16 animation::nbr_of_frames | ( | ) | const [inline] |
Returns the number of frames in this animation.
Definition at line 496 of file animation.h.
u_int16 animation::nbr_of_images | ( | ) | const [inline] |
Returns the number of images in this animation.
Definition at line 507 of file animation.h.
u_int16 animation::currentframe | ( | ) | const [inline] |
Returns the index of the currently displayed frame.
Definition at line 518 of file animation.h.
void animation::set_currentframe | ( | u_int16 | framenbr | ) | [inline] |
Sets the current frame.
framenbr | the index of the frame to display now. |
Definition at line 528 of file animation.h.
s_int16 animation::xoffset | ( | ) | const [inline] |
Returns the global X offset of the animation.
Definition at line 540 of file animation.h.
s_int16 animation::yoffset | ( | ) | const [inline] |
Returns the global Y offset of the animation.
Definition at line 551 of file animation.h.
void animation::set_offset | ( | s_int16 | x, |
s_int16 | y | ||
) | [inline] |
Set the global offsets of this animation.
x | new X global offset. |
y | new Y global offset. |
Definition at line 562 of file animation.h.
animationframe* animation::get_frame | ( | u_int16 | nbr | ) | [inline] |
Returns a pointer to a desired frame.
nbr | the index of the frame to get. |
Definition at line 586 of file animation.h.
image* animation::get_image | ( | u_int16 | nbr | ) | [inline] |
Returns a pointer to a desired image.
nbr | the index of the image to get. |
Definition at line 598 of file animation.h.
s_int8 animation::insert_image | ( | const image * | im, |
u_int16 | pos | ||
) |
Inserts an image at a given position of the image array.
All the frames will be updated so the operation doesn't affect the animation in any way.
The animation will be responsible for freeing the inserted image.
im | pointer to the image to add. |
pos | index where to add the image. |
Definition at line 261 of file animation.cc.
s_int8 animation::insert_frame | ( | const animationframe | af, |
u_int16 | pos | ||
) |
Inserts a frame at a given position of the animationframe array.
All the frames will be updated so the operation doesn't affect the animation in any way.
af | the animationframe to add. |
pos | index where to add the frame. |
Definition at line 304 of file animation.cc.
s_int8 animation::delete_image | ( | u_int16 | pos | ) |
Removes an image at a given position.
The image itself will also be deleted (). All the frames will be updated so the operation doesn't affect the animation in any way.
pos | The index of the image to remove. |
Definition at line 282 of file animation.cc.
s_int8 animation::delete_frame | ( | u_int16 | pos | ) |
Removes a frame at a given position.
All the frames will be updated so the operation doesn't affect the animation in any way.
pos | The index of the animationframe to remove. |
Definition at line 324 of file animation.cc.
void animation::zoom | ( | u_int16 | sx, |
u_int16 | sy, | ||
const animation * | src | ||
) |
Zooms an animation.
sx | Desired X size. |
sy | Desired Y size. |
src | Source animation to zoom. |
Definition at line 347 of file animation.cc.
Animation copy (similar to copy ()).
Definition at line 370 of file animation.cc.
void animation::copy | ( | const animation & | src | ) | [inline] |
Synonym of operator = to guarantee its access from Python.
Definition at line 687 of file animation.h.