Struct Engine::SpriteComponent¶
ClassList > Engine > SpriteComponent
Component that holds a Sprite to be rendered.More...
#include <SpriteComponent.hpp>
Public Attributes¶
| Type | Name |
|---|---|
| std::string | assetPath The file path or alias used to load the sprite from AssetManager . |
| bool | flipX = falseMirrors the sprite horizontally, about its own drawn centre. |
| bool | flipY = falseMirrors the sprite vertically, about its own drawn centre. Purely visual. |
| float | offsetX Horizontal offset from Position.x to the sprite's top-left corner. |
| float | offsetY Vertical offset from Position.y to the sprite's top-left corner. |
| float | scaleX = 1.0fHorizontal scale multiplier of the sprite. |
| float | scaleY = 1.0fVertical scale multiplier of the sprite. |
| std::shared_ptr< Sprite > | sprite Shared pointer to the underlying Sprite . |
Public Functions¶
| Type | Name |
|---|---|
| SpriteComponent (std::shared_ptr< Sprite > spritePtr=nullptr, const std::string & path="", float offsetX=0.0f, float offsetY=0.0f, float scaleX=1.0f, float scaleY=1.0f, bool flipX=false, bool flipY=false) Constructs a SpriteComponent with an optional existing sprite pointer. |
Detailed Description¶
World-space position comes from the Position on the same entity. The sprite is drawn at (Position.x + offsetX, Position.y + offsetY).
Public Attributes Documentation¶
variable assetPath¶
The file path or alias used to load the sprite from AssetManager .
variable flipX¶
Mirrors the sprite horizontally, about its own drawn centre.
Purely visual: the position, the collider and the children are untouched, so a walker that turns around still needs its rig mirrored (see the Component.flipX Lua helper, which flips the sprite and the subtree).
variable flipY¶
Mirrors the sprite vertically, about its own drawn centre. Purely visual.
variable offsetX¶
Horizontal offset from Position.x to the sprite's top-left corner.
variable offsetY¶
Vertical offset from Position.y to the sprite's top-left corner.
variable scaleX¶
Horizontal scale multiplier of the sprite.
variable scaleY¶
Vertical scale multiplier of the sprite.
variable sprite¶
Shared pointer to the underlying Sprite .
Public Functions Documentation¶
function SpriteComponent¶
Constructs a SpriteComponent with an optional existing sprite pointer.
inline Engine::SpriteComponent::SpriteComponent (
std::shared_ptr< Sprite > spritePtr=nullptr,
const std::string & path="",
float offsetX=0.0f,
float offsetY=0.0f,
float scaleX=1.0f,
float scaleY=1.0f,
bool flipX=false,
bool flipY=false
)
Parameters:
spritePtrA shared pointer to an existing Sprite. Defaults to nullptr.pathThe file path or alias of the asset.offsetXOffset from entity position on X.offsetYOffset from entity position on Y.scaleXHorizontal scale. Defaults to 1.0f.scaleYVertical scale. Defaults to 1.0f.flipXMirror horizontally. Defaults to false.flipYMirror vertically. Defaults to false.
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Components/SpriteComponent.hpp