Sprite
Abstract base class for drawable game objects with a texture and transform.
Constructor
-
Sprite() -
Sprite(texture: Texture) -
Sprite(texture: Texture, transform: Transform)
This class cannot be instantiated directly. Inherit from it and implement the update() method.
Parameters
texture: The sprite's texture.transform: The sprite's Transform.
Properties
| Name | Description | Type |
|---|---|---|
transform | The sprite's position, rotation, and scale | Transform |
velocity | The sprite's velocity vector | Vec2 |
texture | The sprite's texture (can be None) | Texture |
visible | Whether the sprite should be drawn | bool |
clip | Source rectangle for texture sampling (None = full texture) | Rect |
Methods
Draw
draw() → NoneDraw the sprite to the screen with its current transform.
Update
update() → NoneUpdate the sprite state.
Note:
This method must be overridden in subclasses.
Move
move() → NoneApply frame-independent velocity to position.