Documentation
¶
Overview ¶
An animation player is used for general-purpose playback of animations. It contains a dictionary of AnimationLibrary resources and custom blend times between animation transitions.
Some methods and properties use a single key to reference an animation directly. These keys are formatted as the key for the library, followed by a forward slash, then the key for the animation within the library, for example "movement/run". If the library's key is an empty string (known as the default library), the forward slash is omitted, being the same key used by the library.
AnimationPlayer is better-suited than Tween for more complex animations, for example ones with non-trivial timings. It can also be used over Tween if the animation track editor is more convenient than doing it in code.
Updating the target properties of animations occurs at the process frame.
Index ¶
- type Advanced
- type AnimationMethodCallMode
- type AnimationProcessCallback
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AnimationGetNext(animation_from string) string
- func (self Instance) AnimationSetNext(animation_from string, animation_to string)
- func (self Instance) AsAnimationMixer() AnimationMixer.Instance
- func (self Instance) AsAnimationPlayer() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AssignedAnimation() string
- func (self Instance) Autoplay() string
- func (self Instance) ClearQueue()
- func (self Instance) CurrentAnimation() string
- func (self Instance) CurrentAnimationLength() Float.X
- func (self Instance) CurrentAnimationPosition() Float.X
- func (self Instance) GetBlendTime(animation_from string, animation_to string) Float.X
- func (self Instance) GetMethodCallMode() AnimationMethodCallMode
- func (self Instance) GetPlayingSpeed() Float.X
- func (self Instance) GetProcessCallback() AnimationProcessCallback
- func (self Instance) GetQueue() []string
- func (self Instance) GetRoot() string
- func (self Instance) GetSectionEndTime() Float.X
- func (self Instance) GetSectionStartTime() Float.X
- func (self Instance) HasSection() bool
- func (self Instance) ID() ID
- func (self Instance) IsPlaying() bool
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) MovieQuitOnFinish() bool
- func (self Instance) OnAnimationChanged(cb func(old_name string, new_name string), flags ...Signal.Flags)
- func (self Instance) OnCurrentAnimationChanged(cb func(name string), flags ...Signal.Flags)
- func (self Instance) Pause()
- func (self Instance) Play()
- func (self Instance) PlayBackwards()
- func (self Instance) PlayNamed(anim_name string)
- func (self Instance) PlaySection()
- func (self Instance) PlaySectionBackwards()
- func (self Instance) PlaySectionWithMarkers()
- func (self Instance) PlaySectionWithMarkersBackwards()
- func (self Instance) PlayWithCapture()
- func (self Instance) PlaybackAutoCapture() bool
- func (self Instance) PlaybackAutoCaptureDuration() Float.X
- func (self Instance) PlaybackAutoCaptureEaseType() Tween.EaseType
- func (self Instance) PlaybackAutoCaptureTransitionType() Tween.TransitionType
- func (self Instance) PlaybackDefaultBlendTime() Float.X
- func (self Instance) Queue(name string)
- func (self Instance) ResetSection()
- func (self Instance) SeekTo(seconds Float.X)
- func (self Instance) SetAssignedAnimation(value string)
- func (self Instance) SetAutoplay(value string)
- func (self Instance) SetBlendTime(animation_from string, animation_to string, sec Float.X)
- func (self Instance) SetCurrentAnimation(value string)
- func (self Instance) SetMethodCallMode(mode AnimationMethodCallMode)
- func (self Instance) SetMovieQuitOnFinish(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPlaybackAutoCapture(value bool)
- func (self Instance) SetPlaybackAutoCaptureDuration(value Float.X)
- func (self Instance) SetPlaybackAutoCaptureEaseType(value Tween.EaseType)
- func (self Instance) SetPlaybackAutoCaptureTransitionType(value Tween.TransitionType)
- func (self Instance) SetPlaybackDefaultBlendTime(value Float.X)
- func (self Instance) SetProcessCallback(mode AnimationProcessCallback)
- func (self Instance) SetRoot(path string)
- func (self Instance) SetSection()
- func (self Instance) SetSectionWithMarkers()
- func (self Instance) SetSpeedScale(value Float.X)
- func (self Instance) SpeedScale() Float.X
- func (self Instance) Stop()
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
- func (self MoreArgs) Play(name string, custom_blend Float.X, custom_speed Float.X, from_end bool)
- func (self MoreArgs) PlayBackwards(name string, custom_blend Float.X)
- func (self MoreArgs) PlaySection(name string, start_time Float.X, end_time Float.X, custom_blend Float.X, ...)
- func (self MoreArgs) PlaySectionBackwards(name string, start_time Float.X, end_time Float.X, custom_blend Float.X)
- func (self MoreArgs) PlaySectionWithMarkers(name string, start_marker string, end_marker string, custom_blend Float.X, ...)
- func (self MoreArgs) PlaySectionWithMarkersBackwards(name string, start_marker string, end_marker string, custom_blend Float.X)
- func (self MoreArgs) PlayWithCapture(name string, duration Float.X, custom_blend Float.X, custom_speed Float.X, ...)
- func (self MoreArgs) SeekTo(seconds Float.X, update bool, update_only bool)
- func (self MoreArgs) SetSection(start_time Float.X, end_time Float.X)
- func (self MoreArgs) SetSectionWithMarkers(start_marker string, end_marker string)
- func (self MoreArgs) Stop(keep_state bool)
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 AnimationMethodCallMode ¶
type AnimationMethodCallMode int //gd:AnimationPlayer.AnimationMethodCallMode
const ( AnimationMethodCallDeferred AnimationMethodCallMode = 0 AnimationMethodCallImmediate AnimationMethodCallMode = 1 )
type AnimationProcessCallback ¶
type AnimationProcessCallback int //gd:AnimationPlayer.AnimationProcessCallback
const ( AnimationProcessPhysics AnimationProcessCallback = 0 AnimationProcessIdle AnimationProcessCallback = 1 AnimationProcessManual AnimationProcessCallback = 2 )
type Extension ¶
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]) AsAnimationMixer ¶
func (self *Extension[T]) AsAnimationMixer() AnimationMixer.Instance
func (*Extension[T]) AsAnimationPlayer ¶
type 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.
type Instance ¶
type Instance [1]gdclass.AnimationPlayer
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 (Instance) AnimationGetNext ¶
Returns the key of the animation which is queued to play after the 'animation_from' animation.
func (Instance) AnimationSetNext ¶
Triggers the 'animation_to' animation when the 'animation_from' animation completes.
func (Instance) AsAnimationMixer ¶
func (self Instance) AsAnimationMixer() AnimationMixer.Instance
func (Instance) AsAnimationPlayer ¶
func (Instance) AssignedAnimation ¶
func (Instance) ClearQueue ¶
func (self Instance) ClearQueue()
Clears all queued, unplayed animations.
func (Instance) CurrentAnimation ¶
func (Instance) CurrentAnimationLength ¶
func (Instance) CurrentAnimationPosition ¶
func (Instance) GetBlendTime ¶
Returns the blend time (in seconds) between two animations, referenced by their keys.
func (Instance) GetMethodCallMode ¶
func (self Instance) GetMethodCallMode() AnimationMethodCallMode
Returns the call mode used for "Call Method" tracks.
func (Instance) GetPlayingSpeed ¶
Returns the actual playing speed of current animation or 0 if not playing. This speed is the SpeedScale property multiplied by custom_speed argument specified when calling the Play method.
Returns a negative value if the current animation is playing backwards.
func (Instance) GetProcessCallback ¶
func (self Instance) GetProcessCallback() AnimationProcessCallback
Returns the process notification in which to update animations.
func (Instance) GetSectionEndTime ¶
Returns the end time of the section currently being played.
func (Instance) GetSectionStartTime ¶
Returns the start time of the section currently being played.
func (Instance) HasSection ¶
Returns true if an animation is currently playing with a section.
func (Instance) IsPlaying ¶
Returns true if an animation is currently playing (even if SpeedScale and/or custom_speed are 0).
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) MovieQuitOnFinish ¶
func (Instance) OnAnimationChanged ¶
func (Instance) OnCurrentAnimationChanged ¶
func (Instance) Pause ¶
func (self Instance) Pause()
Pauses the currently playing animation. The CurrentAnimationPosition will be kept and calling Play or PlayBackwards without arguments or with the same animation name as AssignedAnimation will resume the animation.
See also Stop.
func (Instance) Play ¶
func (self Instance) Play()
Plays the animation with key 'name'. Custom blend times and speed can be set.
The 'from_end' option only affects when switching to a new animation track, or if the same track but at the start or end. It does not affect resuming playback that was paused in the middle of an animation. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling PlayBackwards).
The AnimationPlayer keeps track of its current or last played animation with AssignedAnimation. 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.
Note: The animation will be updated the next time the AnimationPlayer is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).
func (Instance) PlayBackwards ¶
func (self Instance) PlayBackwards()
Plays the animation with key 'name' in reverse.
This method is a shorthand for Play with custom_speed = -1.0 and from_end = true, so see its description for more information.
func (Instance) PlaySection ¶
func (self Instance) PlaySection()
Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time'. See also Play.
Setting 'start_time' to a value outside the range of the animation means the start of the animation will be used instead, and setting 'end_time' to a value outside the range of the animation means the end of the animation will be used instead. 'start_time' cannot be equal to 'end_time'.
func (Instance) PlaySectionBackwards ¶
func (self Instance) PlaySectionBackwards()
Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time' in reverse.
This method is a shorthand for PlaySection with custom_speed = -1.0 and from_end = true, see its description for more information.
func (Instance) PlaySectionWithMarkers ¶
func (self Instance) PlaySectionWithMarkers()
Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker'.
If the start marker is empty, the section starts from the beginning of the animation. If the end marker is empty, the section ends on the end of the animation. See also Play.
func (Instance) PlaySectionWithMarkersBackwards ¶
func (self Instance) PlaySectionWithMarkersBackwards()
Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker' in reverse.
This method is a shorthand for PlaySectionWithMarkers with custom_speed = -1.0 and from_end = true, see its description for more information.
func (Instance) PlayWithCapture ¶
func (self Instance) PlayWithCapture()
See also AnimationMixer.Capture.
You can use this method to use more detailed options for capture than those performed by PlaybackAutoCapture. When PlaybackAutoCapture is false, this method is almost the same as the following:
animationMixer.MoreArgs().Capture(name("run"), duration(0.2), Tween.TransitionType(0), Tween.EaseType(0)) animationPlayer.MoreArgs().PlayWithCapture(name("run"), duration(0.5), custom_blend(1), custom_speed(1), from_end(false), Tween.TransitionType(0), Tween.EaseType(0))
If 'name' is blank, it specifies AssignedAnimation.
If 'duration' is a negative value, the duration is set to the interval between the current position and the first key, when 'from_end' is true, uses the interval between the current position and the last key instead.
Note: The 'duration' takes SpeedScale into account, but 'custom_speed' does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.
func (Instance) PlaybackAutoCapture ¶
func (Instance) PlaybackAutoCaptureDuration ¶
func (Instance) PlaybackAutoCaptureEaseType ¶
func (Instance) PlaybackAutoCaptureTransitionType ¶
func (self Instance) PlaybackAutoCaptureTransitionType() Tween.TransitionType
func (Instance) PlaybackDefaultBlendTime ¶
func (Instance) Queue ¶
Queues an animation for playback once the current animation and all previously queued animations are done.
Note: If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
func (Instance) ResetSection ¶
func (self Instance) ResetSection()
Resets the current section. Does nothing if a section has not been set.
func (Instance) SeekTo ¶
Seeks the animation to the 'seconds' point in time (in seconds). If 'update' is true, the animation updates too, otherwise it updates at process time. Events between the current frame and 'seconds' are skipped.
If 'update_only' is true, the method / audio / animation playback tracks will not be processed.
Note: Seeking to the end of the animation doesn't emit OnAnimationmixer.AnimationFinished. If you want to skip animation and emit the signal, use AnimationMixer.Advance.
func (Instance) SetAssignedAnimation ¶
func (Instance) SetAutoplay ¶
func (Instance) SetBlendTime ¶
Specifies a blend time (in seconds) between two animations, referenced by their keys.
func (Instance) SetCurrentAnimation ¶
func (Instance) SetMethodCallMode ¶
func (self Instance) SetMethodCallMode(mode AnimationMethodCallMode)
Sets the call mode used for "Call Method" tracks.
func (Instance) SetMovieQuitOnFinish ¶
func (Instance) SetPlaybackAutoCapture ¶
func (Instance) SetPlaybackAutoCaptureDuration ¶
func (Instance) SetPlaybackAutoCaptureEaseType ¶
func (Instance) SetPlaybackAutoCaptureTransitionType ¶
func (self Instance) SetPlaybackAutoCaptureTransitionType(value Tween.TransitionType)
func (Instance) SetPlaybackDefaultBlendTime ¶
func (Instance) SetProcessCallback ¶
func (self Instance) SetProcessCallback(mode AnimationProcessCallback)
Sets the process notification in which to update animations.
func (Instance) SetSection ¶
func (self Instance) SetSection()
Changes the start and end times of the section being played. The current playback position will be clamped within the new section. See also PlaySection.
func (Instance) SetSectionWithMarkers ¶
func (self Instance) SetSectionWithMarkers()
Changes the start and end markers of the section being played. The current playback position will be clamped within the new section. See also PlaySectionWithMarkers.
If the argument is empty, the section uses the beginning or end of the animation. If both are empty, it means that the section is not set.
func (Instance) SetSpeedScale ¶
func (Instance) SpeedScale ¶
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 Pause.
If 'keep_state' is true, the animation state is not updated visually.
Note: The method / audio / animation playback tracks will not be processed by this method.
type MoreArgs ¶
type MoreArgs [1]gdclass.AnimationPlayer
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) Play ¶
Plays the animation with key 'name'. Custom blend times and speed can be set.
The 'from_end' option only affects when switching to a new animation track, or if the same track but at the start or end. It does not affect resuming playback that was paused in the middle of an animation. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling PlayBackwards).
The AnimationPlayer keeps track of its current or last played animation with AssignedAnimation. 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.
Note: The animation will be updated the next time the AnimationPlayer is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).
func (MoreArgs) PlayBackwards ¶
Plays the animation with key 'name' in reverse.
This method is a shorthand for Play with custom_speed = -1.0 and from_end = true, so see its description for more information.
func (MoreArgs) PlaySection ¶
func (self MoreArgs) PlaySection(name string, start_time Float.X, end_time Float.X, custom_blend Float.X, custom_speed Float.X, from_end bool)
Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time'. See also Play.
Setting 'start_time' to a value outside the range of the animation means the start of the animation will be used instead, and setting 'end_time' to a value outside the range of the animation means the end of the animation will be used instead. 'start_time' cannot be equal to 'end_time'.
func (MoreArgs) PlaySectionBackwards ¶
func (self MoreArgs) PlaySectionBackwards(name string, start_time Float.X, end_time Float.X, custom_blend Float.X)
Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time' in reverse.
This method is a shorthand for PlaySection with custom_speed = -1.0 and from_end = true, see its description for more information.
func (MoreArgs) PlaySectionWithMarkers ¶
func (self MoreArgs) PlaySectionWithMarkers(name string, start_marker string, end_marker string, custom_blend Float.X, custom_speed Float.X, from_end bool)
Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker'.
If the start marker is empty, the section starts from the beginning of the animation. If the end marker is empty, the section ends on the end of the animation. See also Play.
func (MoreArgs) PlaySectionWithMarkersBackwards ¶
func (self MoreArgs) PlaySectionWithMarkersBackwards(name string, start_marker string, end_marker string, custom_blend Float.X)
Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker' in reverse.
This method is a shorthand for PlaySectionWithMarkers with custom_speed = -1.0 and from_end = true, see its description for more information.
func (MoreArgs) PlayWithCapture ¶
func (self MoreArgs) PlayWithCapture(name string, duration Float.X, custom_blend Float.X, custom_speed Float.X, from_end bool, trans_type Tween.TransitionType, ease_type Tween.EaseType)
See also AnimationMixer.Capture.
You can use this method to use more detailed options for capture than those performed by PlaybackAutoCapture. When PlaybackAutoCapture is false, this method is almost the same as the following:
animationMixer.MoreArgs().Capture(name("run"), duration(0.2), Tween.TransitionType(0), Tween.EaseType(0)) animationPlayer.MoreArgs().PlayWithCapture(name("run"), duration(0.5), custom_blend(1), custom_speed(1), from_end(false), Tween.TransitionType(0), Tween.EaseType(0))
If 'name' is blank, it specifies AssignedAnimation.
If 'duration' is a negative value, the duration is set to the interval between the current position and the first key, when 'from_end' is true, uses the interval between the current position and the last key instead.
Note: The 'duration' takes SpeedScale into account, but 'custom_speed' does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.
func (MoreArgs) SeekTo ¶
Seeks the animation to the 'seconds' point in time (in seconds). If 'update' is true, the animation updates too, otherwise it updates at process time. Events between the current frame and 'seconds' are skipped.
If 'update_only' is true, the method / audio / animation playback tracks will not be processed.
Note: Seeking to the end of the animation doesn't emit OnAnimationmixer.AnimationFinished. If you want to skip animation and emit the signal, use AnimationMixer.Advance.
func (MoreArgs) SetSection ¶
Changes the start and end times of the section being played. The current playback position will be clamped within the new section. See also PlaySection.
func (MoreArgs) SetSectionWithMarkers ¶
Changes the start and end markers of the section being played. The current playback position will be clamped within the new section. See also PlaySectionWithMarkers.
If the argument is empty, the section uses the beginning or end of the animation. If both are empty, it means that the section is not set.
func (MoreArgs) Stop ¶
Stops the currently playing animation. The animation position is reset to 0 and the custom_speed is reset to 1.0. See also Pause.
If 'keep_state' is true, the animation state is not updated visually.
Note: The method / audio / animation playback tracks will not be processed by this method.