SpriteRefs refer to a single sprite on a single cube. More...
#include <sifteo/video/sprite.h>
Public Member Functions | |
unsigned | height () const |
Get this sprite's current image height, in pixels. | |
void | hide () const |
Hide a sprite. More... | |
bool | isHidden () const |
Is this sprite hidden? More... | |
void | move (int x, int y) const |
Move this sprite to a new location, in pixels. More... | |
void | move (Int2 pos) const |
Move this sprite to a new location, in pixels, passed as an Int2. More... | |
void | move (Float2 pos) const |
Move this sprite to a new location, in pixels, passed as a Float2. More... | |
Byte2 | position () const |
Get this sprite's current position as a vector, in pixels. | |
void | resize (unsigned x, unsigned y) const |
Set this sprite's size, in pixels. | |
void | resize (UInt2 size) const |
Set this sprite's size, in pixels, from a UInt2. | |
void | setHeight (unsigned pixels) const |
Set this sprite's height, in pixels. | |
void | setImage (uint16_t tile) const |
Set the sprite's image, given the physical address of the first tile in a pinned asset. More... | |
void | setImage (const PinnedAssetImage &asset, int frame=0) const |
Set a sprite's image and size, given a PinnedAssetImage and optionally a frame number. | |
void | setWidth (unsigned pixels) const |
Set this sprite's width, in pixels. | |
UByte2 | size () const |
Get this sprite's current image size as a vector, in pixels. | |
unsigned | width () const |
Get this sprite's current image width, in pixels. | |
unsigned | x () const |
Get this sprite's current X position, in pixels. | |
unsigned | y () const |
Get this sprite's current Y position, in pixels. | |
SpriteRefs refer to a single sprite on a single cube.
Typically these are transient objects which let you access one sprite's state inside a VideoBuffer, but if necessary you can store SpriteRefs.
A SpriteRef acts as an accessor for memory which is part of your VideoBuffer. When you change sprite parameters using a SpriteRef, you're modifying VRAM which is interpreted by the BG0_SPR_BG1 mode.
The sprite layer exists between BG0 and BG1, and it can have up to SpriteLayer::NUM_SPRITES (8) sprites on it. Sprites are Z-ordered according to their ID. Their dimensions must be a power of two on each axis, and their image must be a 'pinned' asset, i.e. an asset where every tile is stored sequentially in memory with no deduplication.
|
inline |
Hide a sprite.
This effectively disables the sprite, causing the cube to skip it when rendering the next frame.
|
inline |
Is this sprite hidden?
Returns true if he sprite was hidden by hide(). Note that, internally, sprites are hidden by giving them a height of zero. Resizing a sprite, including resizing via setImage, will show the sprite again.
|
inline |
Move this sprite to a new location, in pixels.
This specifies the location of the sprite's top-left corner, measured relative to the top-left corner of the screen. Sprite locations may be negative.
|
inline |
Move this sprite to a new location, in pixels, passed as an Int2.
This specifies the location of the sprite's top-left corner, measured relative to the top-left corner of the screen. Sprite locations may be negative.
|
inline |
Move this sprite to a new location, in pixels, passed as a Float2.
This specifies the location of the sprite's top-left corner, measured relative to the top-left corner of the screen. Sprite locations may be negative. Coordinates are rounded to the nearest integer pixel.
|
inline |
Set the sprite's image, given the physical address of the first tile in a pinned asset.
This is a lower-level method that you typically won't use directly. Does not resize the sprite.
Sifteo SDK v1.1.0 (see all versions)
Last updated Tue Dec 23 2014, by Doxygen