AnimatedSprite2D

package
v0.0.0-...-0d6c339 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

graphics.gd/classdb/AnimatedSprite2D is similar to the graphics.gd/classdb/Sprite2D node, except it carries multiple textures as animation frames. Animations are created using a graphics.gd/classdb/SpriteFrames resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The graphics.gd/classdb/SpriteFrames resource can be configured in the editor via the SpriteFrames bottom panel.

Index

Constants

This section is empty.

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
	AsAnimatedSprite2D() Instance
}

type Expanded

type Expanded [1]gdclass.AnimatedSprite2D

func (Expanded) Play

func (self Expanded) Play(name string, custom_speed Float.X, from_end bool)

Plays the animation with key 'name'. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling Instance.PlayBackwards).

If this method is called with that same animation 'name', or with no 'name' parameter, the assigned animation will resume playing if it was paused.

func (Expanded) PlayBackwards

func (self Expanded) PlayBackwards(name string)

Plays the animation with key 'name' in reverse.

This method is a shorthand for Instance.Play with custom_speed = -1.0 and from_end = true, so see its description for more information.

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]) AsAnimatedSprite2D

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

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

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

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.AnimatedSprite2D

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) Animation

func (self Instance) Animation() string

func (Instance) AsAnimatedSprite2D

func (self Instance) AsAnimatedSprite2D() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

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

func (Instance) Autoplay

func (self Instance) Autoplay() string

func (Instance) Centered

func (self Instance) Centered() bool

func (Instance) FlipH

func (self Instance) FlipH() bool

func (Instance) FlipV

func (self Instance) FlipV() bool

func (Instance) Frame

func (self Instance) Frame() int

func (Instance) FrameProgress

func (self Instance) FrameProgress() Float.X

func (Instance) GetPlayingSpeed

func (self Instance) GetPlayingSpeed() Float.X

Returns the actual playing speed of current animation or 0 if not playing. This speed is the Instance.SpeedScale property multiplied by custom_speed argument specified when calling the Instance.Play method.

Returns a negative value if the current animation is playing backwards.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsPlaying

func (self Instance) IsPlaying() bool

Returns true if an animation is currently playing (even if Instance.SpeedScale and/or custom_speed are 0).

func (Instance) Offset

func (self Instance) Offset() Vector2.XY

func (Instance) OnAnimationChanged

func (self Instance) OnAnimationChanged(cb func(), flags ...Signal.Flags)

func (Instance) OnAnimationFinished

func (self Instance) OnAnimationFinished(cb func(), flags ...Signal.Flags)

func (Instance) OnAnimationLooped

func (self Instance) OnAnimationLooped(cb func(), flags ...Signal.Flags)

func (Instance) OnFrameChanged

func (self Instance) OnFrameChanged(cb func(), flags ...Signal.Flags)

func (Instance) OnSpriteFramesChanged

func (self Instance) OnSpriteFramesChanged(cb func(), flags ...Signal.Flags)

func (Instance) Pause

func (self Instance) Pause()

Pauses the currently playing animation. The Instance.Frame and Instance.FrameProgress will be kept and calling Instance.Play or Instance.PlayBackwards without arguments will resume the animation from the current playback position.

See also Instance.Stop.

func (Instance) Play

func (self Instance) Play()

Plays the animation with key 'name'. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling Instance.PlayBackwards).

If this method is called with that same animation 'name', or with no 'name' parameter, the assigned animation will resume playing if it was paused.

func (Instance) PlayBackwards

func (self Instance) PlayBackwards()

Plays the animation with key 'name' in reverse.

This method is a shorthand for Instance.Play with custom_speed = -1.0 and from_end = true, so see its description for more information.

func (Instance) PlayNamed

func (self Instance) PlayNamed(name string)

PlayNamed plays the named animation from the beginning.

func (Instance) SetAnimation

func (self Instance) SetAnimation(value string)

func (Instance) SetAutoplay

func (self Instance) SetAutoplay(value string)

func (Instance) SetCentered

func (self Instance) SetCentered(value bool)

func (Instance) SetFlipH

func (self Instance) SetFlipH(value bool)

func (Instance) SetFlipV

func (self Instance) SetFlipV(value bool)

func (Instance) SetFrame

func (self Instance) SetFrame(value int)

func (Instance) SetFrameAndProgress

func (self Instance) SetFrameAndProgress(frame_ int, progress Float.X)

Sets Instance.Frame and Instance.FrameProgress to the given values. Unlike setting Instance.Frame, this method does not reset the Instance.FrameProgress to 0.0 implicitly.

Example: Change the animation while keeping the same Instance.Frame and Instance.FrameProgress:

var current_frame = animated_sprite.Frame()
var current_progress = animated_sprite.FrameProgress()
animated_sprite.PlayNamed("walk_another_skin")
animated_sprite.SetFrameAndProgress(current_frame, current_progress)

func (Instance) SetFrameProgress

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

func (*Instance) SetObject

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

func (Instance) SetOffset

func (self Instance) SetOffset(value Vector2.XY)

func (Instance) SetSpeedScale

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

func (Instance) SetSpriteFrames

func (self Instance) SetSpriteFrames(value SpriteFrames.Instance)

func (Instance) SpeedScale

func (self Instance) SpeedScale() Float.X

func (Instance) SpriteFrames

func (self Instance) SpriteFrames() SpriteFrames.Instance

func (Instance) Stop

func (self Instance) Stop()

Stops the currently playing animation. The animation position is reset to 0 and the custom_speed is reset to 1.0. See also Instance.Pause.

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