AnimatedTexture

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

AnimatedTexture is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike AnimationPlayer or AnimatedSprite2D, it isn't a Node, but has the advantage of being usable anywhere a Texture2D resource can be used, e.g. in a TileSet.

The playback of the animation is controlled by the SpeedScale property, as well as each frame's duration (see SetFrameDuration). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.

AnimatedTexture currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.

Note: AnimatedTexture doesn't support using AtlasTextures. Each frame needs to be a separate Texture2D.

Warning: The current implementation is not efficient for the modern renderers.

Index

Constants

View Source
const MaxFrames int = 256 //gd:AnimatedTexture.MAX_FRAMES

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsAnimatedTexture() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsAnimatedTexture

func (self *Extension[T]) AsAnimatedTexture() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsTexture

func (self *Extension[T]) AsTexture() Texture.Instance

func (*Extension[T]) AsTexture2D

func (self *Extension[T]) AsTexture2D() Texture2D.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.AnimatedTexture

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsAnimatedTexture

func (self Instance) AsAnimatedTexture() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTexture

func (self Instance) AsTexture() Texture.Instance

func (Instance) AsTexture2D

func (self Instance) AsTexture2D() Texture2D.Instance

func (Instance) CurrentFrame

func (self Instance) CurrentFrame() int

Sets the currently visible frame of the texture. Setting this frame while playing resets the current frame time, so the newly selected frame plays for its whole configured frame duration.

func (Instance) Frames

func (self Instance) Frames() int

Number of frames to use in the animation. While you can create the frames independently with SetFrameTexture, you need to set this value for the animation to take new frames into account. The maximum number of frames is MaxFrames.

func (Instance) GetFrameDuration

func (self Instance) GetFrameDuration(frame_ int) Float.X

Returns the given 'frame”s duration, in seconds.

func (Instance) GetFrameTexture

func (self Instance) GetFrameTexture(frame_ int) Texture2D.Instance

Returns the given frame's Texture2D.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) OneShot

func (self Instance) OneShot() bool

If true, the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set Pause to true.

func (Instance) Pause

func (self Instance) Pause() bool

If true, the animation will pause where it currently is (i.e. at CurrentFrame). The animation will continue from where it was paused when changing this property to false.

func (Instance) SetCurrentFrame

func (self Instance) SetCurrentFrame(value int)

SetCurrentFrame sets the property returned by [GetCurrentFrame].

func (Instance) SetFrameDuration

func (self Instance) SetFrameDuration(frame_ int, duration Float.X)

Sets the duration of any given 'frame'. The final duration is affected by the SpeedScale. If set to 0, the frame is skipped during playback.

func (Instance) SetFrameTexture

func (self Instance) SetFrameTexture(frame_ int, texture Texture2D.Instance)

Assigns a Texture2D to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID Frames - 1.

You can define any number of textures up to MaxFrames, but keep in mind that only frames from 0 to Frames - 1 will be part of the animation.

func (Instance) SetFrames

func (self Instance) SetFrames(value int)

SetFrames sets the property returned by [GetFrames].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOneShot

func (self Instance) SetOneShot(value bool)

SetOneShot sets the property returned by [GetOneShot].

func (Instance) SetPause

func (self Instance) SetPause(value bool)

SetPause sets the property returned by [GetPause].

func (Instance) SetSpeedScale

func (self Instance) SetSpeedScale(value Float.X)

SetSpeedScale sets the property returned by [GetSpeedScale].

func (Instance) SpeedScale

func (self Instance) SpeedScale() Float.X

The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL