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


NameDescriptionType
transformThe sprite's position, rotation, and scaleTransform
velocityThe sprite's velocity vectorVec2
textureThe sprite's texture (can be None)Texture
visibleWhether the sprite should be drawnbool
clipSource rectangle for texture sampling (None = full texture)Rect

Methods


Draw

draw() None

Draw the sprite to the screen with its current transform.

Update

update() None

Update the sprite state.

Note:

This method must be overridden in subclasses.

Move

move() None

Apply frame-independent velocity to position.