class

PointClickEngine::Graphics::Sprites::Sprite

Inherits Reference < Object

Base sprite class for rendering static images

Sprite provides the foundation for all image rendering in the engine. It handles texture loading, positioning, scaling, rotation, and tinting.

Example

sprite = Sprite.new("assets/item.png")
sprite.position = Vector2.new(100, 200)
sprite.scale = 2.0
sprite.tint = Color::RED

Constructors

new(x : Float32, y : Float32, texture_path : String)

Initialize with position and texture path

Source
new(texture_path : String)

Initialize with texture path

Source
new

Initialize empty (for deserialization)

Source

Instance methods

add_effect(effect : Effects::Effect)

Add an effect to the sprite

Source
add_effect(effect_name : String, **params)

Add effect by name with parameters

Source
bounds

Get sprite bounds in world coordinates

Source
center_origin

Set origin to sprite center

Source
cleanup

Cleanup texture resources

Source
clear_effects

Clear all effects

Source
clone

Clone the sprite

Source
contains?(x : Float32, y : Float32) : Bool

Check if point is inside sprite bounds

Source
contains?(point : RL::Vector2) : Bool

Check if vector is inside sprite bounds

Source
draw

Draw the sprite

Source
draw_with_context(context : PointClickEngine::Graphics::RenderContext, position : RL::Vector2 | Nil = nil, tint : RL::Color | Nil = nil)

Draw with render context (for camera-aware rendering)

Source
effects

Effects component

Source
effects=(effects : Effects::EffectComponent | Nil)

Effects component

Source
has_effects?

Check if sprite has any active effects

Source
id

Unique ID for effect tracking

Source
load_texture(path : String)

Load texture from file

Source
origin
Source
origin=(origin : RL::Vector2)
Source
position

Sprite properties

Source
position=(position : RL::Vector2)

Sprite properties

Source
remove_effects_of_type(klass : Effects::Effect.class)

Remove all effects of a type

Source
rotation
Source
rotation=(rotation : Float32)
Source
scale
Source
scale=(scale : Float32)
Source
source_rect

Source rectangle (for sprite sheets)

Source
source_rect=(source_rect : RL::Rectangle | Nil)

Source rectangle (for sprite sheets)

Source
texture

Texture information

Source
texture_path
Source
tint
Source
tint=(tint : RL::Color)
Source
top_left_origin

Set origin to top-left

Source
update(dt : Float32)

Update sprite (for animation or effects)

Source
visible
Source
visible=(visible : Bool)
Source