Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ecs::Sprite Struct Reference

#include <Sprite.hpp>

Public Member Functions

 Sprite ()=default
 Default constructor (white, no texture).
 Sprite (resource::TextureHandle tex)
 Constructs sprite with texture handle.
 Sprite (resource::TextureHandle tex, const glm::vec4 &col)
 Constructs sprite with texture and color tint.

Public Attributes

resource::TextureHandle texture
 Texture resource handle (type-safe).
glm::vec4 color {1.0f, 1.0f, 1.0f, 1.0f}
 Color tint (RGBA, 0-1 range).
glm::vec2 size {1.0f, 1.0f}
 Sprite size in world units ({1,1} at runtime; authored at 100px).
glm::vec2 pivot {0.5f, 0.5f}
 Pivot point (0,0 = bottom-left, 0.5,0.5 = center, 1,1 = top-right).
glm::vec2 uvOffset {0.0f, 0.0f}
 UV coordinate offset for sprite sheets.
glm::vec2 uvScale {1.0f, 1.0f}
 UV coordinate scale for sprite sheets.
i32 layer {0}
 Sorting layer (higher = rendered on top).
i32 order {0}
 Order WITHIN the sorting layer; higher draws on top. The explicit answer that overrides whatever the layer infers — Y-sort, or depth from z — and the only one a Y-sorted layer has. Range -128..127 (clamped).
i32 maskInteraction {0}
 What a SpriteMask drawn before this sprite does to it. Opt-in, so a mask added to a scene cannot make an unrelated sprite disappear.
bool lit {false}
 Lit by the scene's 2D lights (Light), no material needed. Off = unlit.
bool flipX {false}
 Flip sprite horizontally.
bool flipY {false}
 Flip sprite vertically.
SpriteDrawMode drawMode {SpriteDrawMode::Auto}
 How this sprite fills its box; Auto infers it from tileSize and the texture's slice border.
glm::vec2 tileSize {0.0f, 0.0f}
 Tile size in world units for tiling mode ({0,0} = no tiling).
glm::vec2 tileSpacing {0.0f, 0.0f}
 Spacing between tiles in world units ({0,0} = seamless).
glm::vec2 parallax {1.0f, 1.0f}
 Parallax scroll factor per axis. 1 = moves with the world (default, no parallax); <1 = scrolls slower than the camera (appears farther, e.g. a background); 0 = locked to the camera (e.g. a sky). The renderer offsets the sprite by camera_center * (1 - factor).
u32 material {0}
 Custom material ID (0 = use default batch shader).
bool enabled {true}

Detailed Description

Definition at line 78 of file Sprite.hpp.

Constructor & Destructor Documentation

◆ Sprite() [1/3]

esengine::ecs::Sprite::Sprite ( )
default

Default constructor (white, no texture).

◆ Sprite() [2/3]

esengine::ecs::Sprite::Sprite ( resource::TextureHandle tex)
inlineexplicit

Constructs sprite with texture handle.

Parameters
texTexture resource handle

Definition at line 166 of file Sprite.hpp.

References texture.

◆ Sprite() [3/3]

esengine::ecs::Sprite::Sprite ( resource::TextureHandle tex,
const glm::vec4 & col )
inline

Constructs sprite with texture and color tint.

Parameters
texTexture resource handle
colColor tint

Definition at line 173 of file Sprite.hpp.

References color, and texture.

Member Data Documentation

◆ color

glm::vec4 esengine::ecs::Sprite::color {1.0f, 1.0f, 1.0f, 1.0f}

Color tint (RGBA, 0-1 range).

Definition at line 85 of file Sprite.hpp.

Referenced by Sprite(), spriteApplyJS(), and spriteToJS().

◆ drawMode

SpriteDrawMode esengine::ecs::Sprite::drawMode {SpriteDrawMode::Auto}

How this sprite fills its box; Auto infers it from tileSize and the texture's slice border.

Definition at line 135 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ enabled

bool esengine::ecs::Sprite::enabled {true}

Definition at line 157 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ flipX

bool esengine::ecs::Sprite::flipX {false}

Flip sprite horizontally.

Definition at line 125 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ flipY

bool esengine::ecs::Sprite::flipY {false}

Flip sprite vertically.

Definition at line 129 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ layer

i32 esengine::ecs::Sprite::layer {0}

Sorting layer (higher = rendered on top).

Definition at line 105 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ lit

bool esengine::ecs::Sprite::lit {false}

Lit by the scene's 2D lights (Light), no material needed. Off = unlit.

Definition at line 121 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ maskInteraction

i32 esengine::ecs::Sprite::maskInteraction {0}

What a SpriteMask drawn before this sprite does to it. Opt-in, so a mask added to a scene cannot make an unrelated sprite disappear.

Definition at line 117 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ material

u32 esengine::ecs::Sprite::material {0}

Custom material ID (0 = use default batch shader).

Definition at line 154 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ order

i32 esengine::ecs::Sprite::order {0}

Order WITHIN the sorting layer; higher draws on top. The explicit answer that overrides whatever the layer infers — Y-sort, or depth from z — and the only one a Y-sorted layer has. Range -128..127 (clamped).

Definition at line 111 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ parallax

glm::vec2 esengine::ecs::Sprite::parallax {1.0f, 1.0f}

Parallax scroll factor per axis. 1 = moves with the world (default, no parallax); <1 = scrolls slower than the camera (appears farther, e.g. a background); 0 = locked to the camera (e.g. a sky). The renderer offsets the sprite by camera_center * (1 - factor).

Definition at line 150 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ pivot

glm::vec2 esengine::ecs::Sprite::pivot {0.5f, 0.5f}

Pivot point (0,0 = bottom-left, 0.5,0.5 = center, 1,1 = top-right).

Definition at line 93 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ size

glm::vec2 esengine::ecs::Sprite::size {1.0f, 1.0f}

Sprite size in world units ({1,1} at runtime; authored at 100px).

Definition at line 89 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ texture

resource::TextureHandle esengine::ecs::Sprite::texture

Texture resource handle (type-safe).

Definition at line 81 of file Sprite.hpp.

Referenced by Sprite(), Sprite(), spriteApplyJS(), and spriteToJS().

◆ tileSize

glm::vec2 esengine::ecs::Sprite::tileSize {0.0f, 0.0f}

Tile size in world units for tiling mode ({0,0} = no tiling).

Definition at line 139 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ tileSpacing

glm::vec2 esengine::ecs::Sprite::tileSpacing {0.0f, 0.0f}

Spacing between tiles in world units ({0,0} = seamless).

Definition at line 143 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ uvOffset

glm::vec2 esengine::ecs::Sprite::uvOffset {0.0f, 0.0f}

UV coordinate offset for sprite sheets.

Definition at line 97 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().

◆ uvScale

glm::vec2 esengine::ecs::Sprite::uvScale {1.0f, 1.0f}

UV coordinate scale for sprite sheets.

Definition at line 101 of file Sprite.hpp.

Referenced by spriteApplyJS(), and spriteToJS().


The documentation for this struct was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/ecs/components/Sprite.hpp