Skip to content

sprite

FreeBodyEngine.graphics.sprite #

AnimatedSprite2D(animation_set, material, renderer, default_animation=None, position=Vector(), rotation=0.0, scale=Vector(1, 1), visible=True, z=0) #

Bases: Sprite2D

A Sprite2D whose texture is driven by an AnimationPlayer instead of staying fixed. material must already define an albedo property (e.g. loaded from a .fbmat file) - each frame change reassigns it to that frame's texture.

Builds an AnimationPlayer for animation_set, wraps its current frame's texture in a fresh Sprite, and initializes as a Sprite2D with that sprite - so the sprite's texture starts out driven by the animation player from the very first frame.

player = AnimationPlayer(animation_set, default_animation) instance-attribute #

on_update() #

Advances the AnimationPlayer by this frame's delta time and, if that changed the current frame, reassigns the sprite's material albedo to the new frame's texture.

set_animation(name, restart=False) #

Switches the underlying AnimationPlayer to the animation named name, optionally restarting it from frame zero even if it's already the active animation.

Sprite(texture, material, renderer, visisble=True, z=0) #

A drawable unit combining a texture, material, and generated quad mesh, independent of the node tree - Sprite2D/Sprite3D each wrap one to give it a scene position via a Transform.

Stores texture/material/renderer, assigns texture onto the material's albedo property, and generates the flat quad mesh this sprite is drawn with.

material = material instance-attribute #

quad = generate_quad() instance-attribute #

renderer = renderer instance-attribute #

texture = texture instance-attribute #

visisble = visisble instance-attribute #

z = z instance-attribute #

Sprite2D(sprite, position=Vector(), rotaition=0.0, scale=Vector(1, 1)) #

Bases: Node2D

Positions a Sprite in 2D space by wrapping it in a Node2D, so it can be added to the node tree and inherit a world transform - the Sprite itself stays transform-less.

Wraps sprite with a 2D Transform (position/rotaition/ scale) so it can be parented into the node tree.

on_draw() #

Draws the wrapped sprite. Mirrors the Node.on_draw hook pattern (see core/node.py).

Sprite3D(image) #

Bases: Node2D

Intended 3D counterpart to Sprite2D for positioning a Sprite via a 3D transform.

Not yet implemented - accepts an image but does not initialize the node or store anything.