#include <eosim/graphic/Display.hpp>
Public Member Functions | |
Sprite () | |
This operation creates a Sprite with undefined state. It is an error to invoke any operation except assign it to another Sprite. | |
Sprite (Display &dis, const char *file, double x, double y) | |
This is a constructor of Sprite. | |
void | setImage (const char *file) |
This operation asigns an image to the Sprite. The supported file formats are BMP, PNM, XPM, XCF, PCX, GIF, JPG, TIF, PNG y LBM. | |
void | setMoves (MoveAction m) |
This operation assigns a move sequence to a Sprite. | |
void | setVisible (bool v) |
This operation makes the Sprite visible. | |
bool | getVisible () const |
This operation returns true if the Sprite is visible. |
eosim::graphic::Sprite::Sprite | ( | Display & | dis, | |
const char * | file, | |||
double | x, | |||
double | y | |||
) |
void eosim::graphic::Sprite::setMoves | ( | MoveAction | m | ) |
This operation assigns a move sequence to a Sprite.
To move a Sprite we assign a MoveAction to it. A MoveAction has a position and a time. When it is assigned, the Sprite will move from its actual position to the assigned position in the assigned time (waypoint). For example:
my_sprite.setMoves(move(2,4,6));
will move my_sprite from its actual position to (2,4) in 6 time units (it will reach (2,4) in t + 6 if t is the time when Sprite::setMoves is invoked).
It is also possible to assign a sequence of waypoints with this function:
my_sprite.setMoves(move(2,4,6).move(0,0,8));
here the Sprite will go first to (2,4) then to (0,0) in 14 time units (6 to (2,4) then to 8 to (0,0)).
Once those waypoints have been assigned, Display::advance moves sprites and textSprites for their assigned waypoints continously, until there are no more moves assigned. A new invocation of this operation will remove old waypoints and the movement will start from the object actual position.