v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | List of all members
Sifteo::SpriteRef Struct Reference

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.
 

Detailed Description

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.

Member Function Documentation

void Sifteo::SpriteRef::hide ( ) const
inline

Hide a sprite.

This effectively disables the sprite, causing the cube to skip it when rendering the next frame.

bool Sifteo::SpriteRef::isHidden ( ) const
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.

void Sifteo::SpriteRef::move ( int  x,
int  y 
) const
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.

void Sifteo::SpriteRef::move ( Int2  pos) const
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.

void Sifteo::SpriteRef::move ( Float2  pos) const
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.

void Sifteo::SpriteRef::setImage ( uint16_t  tile) const
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.


The documentation for this struct was generated from the following file: