A sprite is a specialized view corresponding to a 2D bitmap-based graphical element. More...
#include <OSDLSprite.h>
Public Types | |
typedef Ceylan::Uint8 | Shape |
Describes a possible shape for a tiled sprite. | |
Public Member Functions | |
Sprite (const std::string &frameFilename) | |
Constructs a new sprite. | |
virtual | ~Sprite () throw () |
Virtual destructor. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
Static Public Member Functions | |
static std::string | DescribeShape (Shape shape) |
Returns a textual description of specified sprite shape. | |
static Shape | GetSmallestEnclosingShape (OSDL::Video::Length width, OSDL::Video::Length height) |
Returns the smallest registered standard sprite shape enclosing a rectangle of specified dimensions. | |
static OSDL::Video::Length | GetShapeWidthFor (Shape shape) |
Returns the width, in pixels, of the sprite shape associated to specified shape. | |
static OSDL::Video::Length | GetShapeHeightFor (Shape shape) |
Returns the height, in pixels, of the sprite shape associated to specified shape. | |
Static Public Attributes | |
static const Shape | EightTimesEight = 1 |
Describes a sprite whose shape is 8x8 pixels. | |
static const Shape | SixteenTimesEight = 2 |
Describes a sprite whose shape is 16x8 pixels. | |
static const Shape | ThirtyTwoTimesEight = 3 |
Describes a sprite whose shape is 32x8 pixels. | |
static const Shape | EightTimesSixteen = 4 |
Describes a sprite whose shape is 8x16 pixels. | |
static const Shape | SixteenTimesSixteen = 5 |
Describes a sprite whose shape is 16x16 pixels. | |
static const Shape | ThirtyTwoTimesSixteen = 6 |
Describes a sprite whose shape is 32x16 pixels. | |
static const Shape | EightTimesThirtyTwo = 7 |
Describes a sprite whose shape is 8x32 pixels. | |
static const Shape | SixteenTimesThirtyTwo = 8 |
Describes a sprite whose shape is 16x32 pixels. | |
static const Shape | ThirtyTwoTimesThirtyTwo = 9 |
Describes a sprite whose shape is 32x32 pixels. | |
static const Shape | SixtyFourTimesThirtyTwo = 10 |
Describes a sprite whose shape is 32x32 pixels. | |
static const Shape | ThirtyTwoTimesSixtyFour = 11 |
Describes a sprite whose shape is 32x64 pixels. | |
static const Shape | SixtyFourTimesSixtyFour = 12 |
Describes a sprite whose shape is 64x64 pixels. | |
static const Shape | PowersOfTwo = 13 |
Describes a sprite whose width and height are powers of two (not necessarily the same one). | |
Protected Attributes | |
bool | _ownBoundingBox |
Tells whether this sprite owns the bounding box(es) it refers to. | |
Engine::BoundingBox2D * | _box |
Each sprite is linked with a bounding box, which graphically contains it. | |
Shape | _shape |
The shape of this sprite. | |
Video::OpenGL::GLTexture * | _texture |
The texture owned by this sprite, if OpenGL is used. | |
Private Member Functions | |
Sprite (const Sprite &source) | |
Copy constructor made private to ensure that it will never be called. | |
Sprite & | operator= (const Sprite &source) |
Assignment operator made private to ensure that it will never be called. |
A sprite is a specialized view corresponding to a 2D bitmap-based graphical element.
Definition at line 111 of file OSDLSprite.h.
typedef Ceylan::Uint8 OSDL::Rendering::Sprite::Shape |
Describes a possible shape for a tiled sprite.
Definition at line 120 of file OSDLSprite.h.
Sprite::Sprite | ( | const std::string & | frameFilename | ) | [explicit] |
Constructs a new sprite.
frameFilename | the filename of the OSDL frame to be used. |
Definition at line 107 of file OSDLSprite.cc.
Sprite::~Sprite | ( | ) | throw () [virtual] |
Virtual destructor.
Definition at line 133 of file OSDLSprite.cc.
References _box, _ownBoundingBox, and _texture.
OSDL::Rendering::Sprite::Sprite | ( | const Sprite & | source | ) | [private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
string Sprite::DescribeShape | ( | Shape | shape | ) | [static] |
Returns a textual description of specified sprite shape.
SpriteException | if the specified shape is not known. |
Definition at line 186 of file OSDLSprite.cc.
References EightTimesEight, EightTimesSixteen, EightTimesThirtyTwo, PowersOfTwo, SixteenTimesEight, SixteenTimesSixteen, SixteenTimesThirtyTwo, SixtyFourTimesSixtyFour, SixtyFourTimesThirtyTwo, ThirtyTwoTimesEight, ThirtyTwoTimesSixteen, ThirtyTwoTimesSixtyFour, and ThirtyTwoTimesThirtyTwo.
Referenced by toString().
Length Sprite::GetShapeHeightFor | ( | Shape | shape | ) | [static] |
Returns the height, in pixels, of the sprite shape associated to specified shape.
shape | the shape whose height is needed. |
SpriteException | if the operation failed, including if the shape is not known. |
Definition at line 385 of file OSDLSprite.cc.
References EightTimesEight, EightTimesSixteen, EightTimesThirtyTwo, SixteenTimesEight, SixteenTimesSixteen, SixteenTimesThirtyTwo, SixtyFourTimesSixtyFour, SixtyFourTimesThirtyTwo, ThirtyTwoTimesEight, ThirtyTwoTimesSixteen, ThirtyTwoTimesSixtyFour, and ThirtyTwoTimesThirtyTwo.
Length Sprite::GetShapeWidthFor | ( | Shape | shape | ) | [static] |
Returns the width, in pixels, of the sprite shape associated to specified shape.
shape | the shape whose width is needed. |
SpriteException | if the operation failed, including if the shape is not known. |
Definition at line 345 of file OSDLSprite.cc.
References EightTimesEight, EightTimesSixteen, EightTimesThirtyTwo, SixteenTimesEight, SixteenTimesSixteen, SixteenTimesThirtyTwo, SixtyFourTimesSixtyFour, SixtyFourTimesThirtyTwo, ThirtyTwoTimesEight, ThirtyTwoTimesSixteen, ThirtyTwoTimesSixtyFour, and ThirtyTwoTimesThirtyTwo.
static Shape OSDL::Rendering::Sprite::GetSmallestEnclosingShape | ( | OSDL::Video::Length | width, | |
OSDL::Video::Length | height | |||
) | [static] |
Returns the smallest registered standard sprite shape enclosing a rectangle of specified dimensions.
width | the width of the rectangle to enclose. | |
height | the height of the rectangle to enclose. |
SpriteException | if no known shape is large enough to contain the specified size. |
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
const string Sprite::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 150 of file OSDLSprite.cc.
References _ownBoundingBox, _shape, _texture, DescribeShape(), and OSDL::Video::OpenGL::GLTexture::toString().
Engine::BoundingBox2D* OSDL::Rendering::Sprite::_box [protected] |
Each sprite is linked with a bounding box, which graphically contains it.
Definition at line 350 of file OSDLSprite.h.
Referenced by ~Sprite().
bool OSDL::Rendering::Sprite::_ownBoundingBox [protected] |
Tells whether this sprite owns the bounding box(es) it refers to.
On a local scheme, the bounding box is shared between the view(s) and the model, since it may use both for rendering and collision detection.
On a distributed context (typically, client/server), multiple bounding boxes exist: one on each client, shared between the views, and one on the server, for the model.
Definition at line 338 of file OSDLSprite.h.
Referenced by toString(), and ~Sprite().
Shape OSDL::Rendering::Sprite::_shape [protected] |
The texture owned by this sprite, if OpenGL is used.
Definition at line 368 of file OSDLSprite.h.
Referenced by toString(), and ~Sprite().
const Sprite::Shape Sprite::EightTimesEight = 1 [static] |
Describes a sprite whose shape is 8x8 pixels.
Definition at line 188 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::EightTimesSixteen = 4 [static] |
Describes a sprite whose shape is 8x16 pixels.
Definition at line 205 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::EightTimesThirtyTwo = 7 [static] |
Describes a sprite whose shape is 8x32 pixels.
Definition at line 222 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::PowersOfTwo = 13 [static] |
Describes a sprite whose width and height are powers of two (not necessarily the same one).
Definition at line 255 of file OSDLSprite.h.
Referenced by DescribeShape().
const Sprite::Shape Sprite::SixteenTimesEight = 2 [static] |
Describes a sprite whose shape is 16x8 pixels.
Definition at line 192 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::SixteenTimesSixteen = 5 [static] |
Describes a sprite whose shape is 16x16 pixels.
Definition at line 209 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::SixteenTimesThirtyTwo = 8 [static] |
Describes a sprite whose shape is 16x32 pixels.
Definition at line 226 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::SixtyFourTimesSixtyFour = 12 [static] |
Describes a sprite whose shape is 64x64 pixels.
Definition at line 247 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::SixtyFourTimesThirtyTwo = 10 [static] |
Describes a sprite whose shape is 32x32 pixels.
Definition at line 234 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::ThirtyTwoTimesEight = 3 [static] |
Describes a sprite whose shape is 32x8 pixels.
Definition at line 196 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::ThirtyTwoTimesSixteen = 6 [static] |
Describes a sprite whose shape is 32x16 pixels.
Definition at line 213 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::ThirtyTwoTimesSixtyFour = 11 [static] |
Describes a sprite whose shape is 32x64 pixels.
Definition at line 243 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().
const Sprite::Shape Sprite::ThirtyTwoTimesThirtyTwo = 9 [static] |
Describes a sprite whose shape is 32x32 pixels.
Definition at line 230 of file OSDLSprite.h.
Referenced by DescribeShape(), GetShapeHeightFor(), and GetShapeWidthFor().