DSC Engine
All Classes Files Functions Variables Typedefs
Public Member Functions | Static Public Member Functions | List of all members
DSC::Sprite Class Reference
Inheritance diagram for DSC::Sprite:
DSC::Localizable

Public Member Functions

 Sprite (ObjSize size, Engine engine)
 
ObjVisualget_visual () const
 gets the sprite visual information More...
 
Size< char > get_size () const
 gets the sprite size More...
 
void update_visual ()
 
void update_position ()
 
void set_position (sf24 x, sf24 y)
 sets the sprite virtual position More...
 
void move (sf24 x, sf24 y)
 moves a sprite relative to its virtual position More...
 
virtual sf24 x () const override
 
virtual sf24 y () const override
 
Engine get_engine () const
 
int add_frame (ObjFrame *frame)
 Adds a new sprite frame. More...
 
void flip_horizontal ()
 
void flip_vertical ()
 
void set_flip_horizontal (bool is_flipped)
 Sets the sprite is horizontal flip state. More...
 
void set_flip_vertical (bool is_flipped)
 Sets the sprite is vertical flip state. More...
 
bool is_flipped_horizontal () const
 
bool is_flipped_vertical () const
 
void set_priority (int priority)
 Sets sprite priority. More...
 
void show ()
 
void hide ()
 
bool is_hidden () const
 
void set_anchor (int anchor_x, int anchor_y)
 Sets sprite anchor relative to hitbox. More...
 
void set_default_allocator (ObjAllocator *obj_allocator)
 
virtual sf24 x () const =0
 Get object x coordinate. More...
 
virtual sf24 y () const =0
 Get object y coordinate. More...
 

Static Public Member Functions

static void oam_deploy_main ()
 
static void oam_deploy_sub ()
 

Member Function Documentation

◆ add_frame()

int DSC::Sprite::add_frame ( ObjFrame frame)

Adds a new sprite frame.

Parameters
frameObject Frame specifying the spritesheet and frame coordinates
Returns
frame id to be used when setting the frame for display, also when including the frame into animated framesets

◆ flip_horizontal()

void DSC::Sprite::flip_horizontal ( )

Flips the sprite horizontally

◆ flip_vertical()

void DSC::Sprite::flip_vertical ( )

Flips the sprite vertically

◆ get_engine()

Engine DSC::Sprite::get_engine ( ) const

Gets sprite owner engine (Main/Sub)

◆ get_size()

Size< char > DSC::Sprite::get_size ( ) const

gets the sprite size

Returns
width and height of sprite, in pixels

◆ get_visual()

ObjVisual * DSC::Sprite::get_visual ( ) const

gets the sprite visual information

Returns
pointer to sprite's visual data

◆ hide()

void DSC::Sprite::hide ( )

Hides the sprite

◆ is_flipped_horizontal()

bool DSC::Sprite::is_flipped_horizontal ( ) const

Checks if the sprite is flipped horizontally

◆ is_flipped_vertical()

bool DSC::Sprite::is_flipped_vertical ( ) const

Checks if the sprite is flipped vertically

◆ is_hidden()

bool DSC::Sprite::is_hidden ( ) const

Checks if the sprite is hidden

◆ move()

void DSC::Sprite::move ( sf24  x,
sf24  y 
)

moves a sprite relative to its virtual position

Parameters
xrelative horizontal position
yrelative vertical position

◆ set_anchor()

void DSC::Sprite::set_anchor ( int  anchor_x,
int  anchor_y 
)

Sets sprite anchor relative to hitbox.

Parameters
anchor_xhorizontal anchor (0..255) 0=left-most, 255=right-most, 128=center
anchor_yvertical anchor (0..255) 0=top-most, 255=bottom-most, 128=center

◆ set_flip_horizontal()

void DSC::Sprite::set_flip_horizontal ( bool  is_flipped)

Sets the sprite is horizontal flip state.

Parameters
is_flippedtrue if sprite must be flipped, false otherwise

◆ set_flip_vertical()

void DSC::Sprite::set_flip_vertical ( bool  is_flipped)

Sets the sprite is vertical flip state.

Parameters
is_flippedtrue if sprite must be flipped, false otherwise

◆ set_position()

void DSC::Sprite::set_position ( sf24  x,
sf24  y 
)

sets the sprite virtual position

Parameters
xhorizontal position
yvertical position

The sprite position is actually the logical position and may coincide or not with the real (hardware) position. When interacting with a Camera, the sprite's hardware position is computed from the logical position relative to the camera offset. If the sprite is not in relation with any Camera, then the hardware position is calculated from the logical position relative to the top-left of the screen, when taking into account other details like the anchor and hitbox.

◆ set_priority()

void DSC::Sprite::set_priority ( int  priority)

Sets sprite priority.

Parameters
prioritySprite priority 0..3
Warning
Use this only if you know what you are doing. Messing up with priorities can make sprites display behind backgrounds, in which case it is a potentially hard to detect bug source in larger contexts.

◆ show()

void DSC::Sprite::show ( )

Displays the sprite

◆ update_position()

void DSC::Sprite::update_position ( )

Renders position data to sprite's OAM attribute

◆ update_visual()

void DSC::Sprite::update_visual ( )

Renders visual data to sprite's OAM attribute

◆ x()

virtual sf24 DSC::Sprite::x ( ) const
overridevirtual

Gets sprite horizontal position in the virtual space

Implements DSC::Localizable.

◆ y()

virtual sf24 DSC::Sprite::y ( ) const
overridevirtual

Gets sprite vertical position in the virtual space

Implements DSC::Localizable.


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