← Back to Documentation
Sprite2D
⚠️ Experimental - Pre-Release
Inheritance Hierarchy
Inherits:
Inheritance Chain:
Node → Node2D → Sprite2D
Sprite2D is a 2D sprite node that extends Node2D and can render images. Use Sprite2D to display textures and images in your 2D games.
Basic Usage
@script PlayerSprite extends Sprite2D fn init() { // Sprite2D automatically renders // Set texture or image in scene or via code }Fields
texture: Texture?
The texture to render. Set this to display an image.
@script Player extends Sprite2D fn init() { // Load and set texture self.texture = Texture.load("res://textures/player.png") }region: [float; 4]?
Optional texture region (rectangular area of texture to display). Array of 4 floats.
Note: Sprite2D also has all fields from Node2D: transform, pivot, visible, z_index
