Nox Engine
 
Loading...
Searching...
No Matches
Sprites Struct Reference

A component that gives an entity a visual representation using a texture. More...

#include <Sprites.h>

Inheritance diagram for Sprites:
Inheritance graph
Collaboration diagram for Sprites:
Collaboration graph

Public Member Functions

 Sprites (const char *tex)
 Constructs a sprite from a texture path.
 
 Sprites (const char *tex, int nFrames, int mSpeed, bool loop)
 Constructs a sprite with simple, built-in animation capabilities.
 
void init () override
 Initializes the sprite, getting the entity's transform and loading the texture.
 
void update () override
 Updates the destination rectangle for rendering based on the transform.
 
void draw () override
 Draws the sprite's current texture to the screen.
 
void recalcSpriteDimensions ()
 Recalculates the sprite's on-screen dimensions based on texture size and transform scale.
 
- Public Member Functions inherited from Component
virtual void reload ()
 Called to reset the component's state.
 

Friends

struct Animator
 

Additional Inherited Members

- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Detailed Description

A component that gives an entity a visual representation using a texture.

This component is responsible for drawing a texture at the entity's position. It can be controlled by an Animator component for animated sprites.

Constructor & Destructor Documentation

◆ Sprites() [1/2]

Sprites::Sprites ( const char tex)

Constructs a sprite from a texture path.

Parameters
texThe file path to the texture.
Here is the call graph for this function:

◆ Sprites() [2/2]

Sprites::Sprites ( const char tex,
int  nFrames,
int  mSpeed,
bool  loop 
)

Constructs a sprite with simple, built-in animation capabilities.

Parameters
texThe file path to the sprite sheet.
nFramesThe number of frames in the animation.
mSpeedThe delay in milliseconds between frames.
loopWhether the animation should loop.

Member Function Documentation

◆ draw()

void Sprites::draw ( )
overridevirtual

Draws the sprite's current texture to the screen.

Reimplemented from Component.

Here is the call graph for this function:

◆ init()

void Sprites::init ( )
overridevirtual

Initializes the sprite, getting the entity's transform and loading the texture.

Reimplemented from Component.

Here is the call graph for this function:

◆ update()

void Sprites::update ( )
overridevirtual

Updates the destination rectangle for rendering based on the transform.

Reimplemented from Component.

Here is the call graph for this function:

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