Adonthell
0.4
|
Class that handles animated elements, their update and their playback. More...
#include <animation.h>
Public Member Functions | |
animation () | |
Default constructor. More... | |
~animation () | |
Destructor. More... | |
void | clear () |
Clears an animation, that is put it back into the original (constructor) state. More... | |
Playback control methods. | |
void | play () |
Starts the playback of the animation. More... | |
void | stop () |
Stops the playback of the animation. More... | |
play_state | playstate () const |
Returns whether the animation is currently being played. More... | |
void | rewind () |
Rewinds the animation to it's beginning. More... | |
void | next_frame () |
Directly jumps to the next frame. More... | |
State updating Methods. | |
bool | update () |
Updates the animation state. More... | |
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. More... | |
Saving/Loading Methods. | |
| |
s_int8 | get (igzstream &file) |
Loads an animation from an opened file. More... | |
s_int8 | load (string fname) |
Loads an animation from it's filename. More... | |
s_int8 | put (ogzstream &file) const |
Saves an animation into an opened file, in game format, with alpha and mask values. More... | |
s_int8 | save (string fname) const |
Saves an animation into an file, in game format, with alpha and mask values. More... | |
Global animation properties Methods. | |
u_int16 | nbr_of_frames () const |
Returns the number of frames in this animation. More... | |
u_int16 | nbr_of_images () const |
Returns the number of images in this animation. More... | |
u_int16 | currentframe () const |
Returns the index of the currently displayed frame. More... | |
void | set_currentframe (u_int16 framenbr) |
Sets the current frame. More... | |
s_int16 | xoffset () const |
Returns the global X offset of the animation. More... | |
s_int16 | yoffset () const |
Returns the global Y offset of the animation. More... | |
void | set_offset (s_int16 x, s_int16 y) |
Set the global offsets of this animation. More... | |
Image and Animationframe control Methods. | |
animationframe * | get_frame (u_int16 nbr) |
Returns a pointer to a desired frame. More... | |
image * | get_image (u_int16 nbr) |
Returns a pointer to a desired image. More... | |
s_int8 | insert_image (const image *im, u_int16 pos) |
Inserts an image at a given position of the image array. More... | |
s_int8 | insert_frame (const animationframe af, u_int16 pos) |
Inserts a frame at a given position of the animationframe array. More... | |
s_int8 | delete_image (u_int16 pos) |
Removes an image at a given position. More... | |
s_int8 | delete_frame (u_int16 pos) |
Removes a frame at a given position. More... | |
![]() | |
drawable () | |
Default constructor. More... | |
virtual | ~drawable () |
Destructor. More... | |
u_int16 | length () const |
Returns the length of the drawable. More... | |
u_int16 | height () const |
Returns the height of the drawable. More... | |
virtual bool | input_update () |
Virtual input update function, provided for objects which doesn't need one. More... | |
Special FX methods. | |
class | win_anim |
void | zoom (u_int16 sx, u_int16 sy, const animation *src) |
Zooms an animation. More... | |
animation & | operator= (const animation &src) |
Animation copy (similar to copy ()). More... | |
void | copy (const animation &src) |
Synonym of operator = to guarantee its access from Python. More... | |
Additional Inherited Members | |
![]() | |
void | set_length (u_int16 l) |
Sets the length of the drawable. More... | |
void | set_height (u_int16 h) |
Sets the height of the drawable. More... | |
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 312 of file animation.h.
animation::animation | ( | ) |
Default constructor.
Definition at line 100 of file animation.cc.
animation::~animation | ( | ) |
Destructor.
Definition at line 121 of file animation.cc.
void animation::clear | ( | ) |
Clears an animation, that is put it back into the original (constructor) state.
Definition at line 105 of file animation.cc.
|
inline |
Starts the playback of the animation.
Definition at line 348 of file animation.h.
|
inline |
Stops the playback of the animation.
Definition at line 361 of file animation.h.
|
inline |
Returns whether the animation is currently being played.
Definition at line 376 of file animation.h.
|
inline |
Rewinds the animation to it's beginning.
Definition at line 385 of file animation.h.
void animation::next_frame | ( | ) |
Directly jumps to the next frame.
Definition at line 143 of file animation.cc.
|
virtual |
Updates the animation state.
Reimplemented from drawable.
Definition at line 127 of file animation.cc.
|
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 149 of file animation.cc.
Loads an animation from an opened file.
file | the opened file from which to load. |
Definition at line 163 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 208 of file animation.cc.
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 220 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 252 of file animation.cc.
|
inline |
Returns the number of frames in this animation.
Definition at line 500 of file animation.h.
|
inline |
Returns the number of images in this animation.
Definition at line 511 of file animation.h.
|
inline |
Returns the index of the currently displayed frame.
Definition at line 522 of file animation.h.
|
inline |
Sets the current frame.
framenbr | the index of the frame to display now. |
Definition at line 532 of file animation.h.
|
inline |
Returns the global X offset of the animation.
Definition at line 544 of file animation.h.
|
inline |
Returns the global Y offset of the animation.
Definition at line 555 of file animation.h.
Set the global offsets of this animation.
x | new X global offset. |
y | new Y global offset. |
Definition at line 566 of file animation.h.
|
inline |
Returns a pointer to a desired frame.
nbr | the index of the frame to get. |
Definition at line 590 of file animation.h.
Returns a pointer to a desired image.
nbr | the index of the image to get. |
Definition at line 602 of file animation.h.
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 264 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 307 of file animation.cc.
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 285 of file animation.cc.
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 327 of file animation.cc.
Zooms an animation.
sx | Desired X size. |
sy | Desired Y size. |
src | Source animation to zoom. |
Definition at line 350 of file animation.cc.
Animation copy (similar to copy ()).
Definition at line 373 of file animation.cc.
|
inline |
Synonym of operator = to guarantee its access from Python.
Definition at line 691 of file animation.h.