eosim::graphic::Sprite Class Reference
[Graphic Simulations]

#include <eosim/graphic/Display.hpp>

List of all members.


Detailed Description

Image Sprite.

Author:
Bruno Martínez, Fernando Pardo and Sebastián Alaggia
Version:
1.1.1
Date:
2005
Both Sprite and TextSprite represents objects or text which can be added to the Display (see constructor, moved arround the window (see Sprite::setMoves), change shape or message (see Sprite::setImage and TextSprite::setText), and be removed from the window. The persistency of a Sprite (or TextSprite) is due to number of referencies to them. When they are only referenced by their display, they are deleted and remove from the window.


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.


Constructor & Destructor Documentation

eosim::graphic::Sprite::Sprite ( Display dis,
const char *  file,
double  x,
double  y 
)

This is a constructor of Sprite.

It returns a Sprite assigned to dis. The Sprite is drawn with the image which is in file, placed in (x,y).


Member Function Documentation

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.


Generated on Tue Oct 14 16:49:01 2008 for EOSimulator by  doxygen 1.5.2