Merge pull request #87180 from 31/dev/31/animation-length-ex
Include `animation.length` in Animation example
This commit is contained in:
commit
c16facaa67
1 changed files with 6 additions and 4 deletions
|
@ -8,21 +8,23 @@
|
||||||
[codeblocks]
|
[codeblocks]
|
||||||
[gdscript]
|
[gdscript]
|
||||||
# This creates an animation that makes the node "Enemy" move to the right by
|
# This creates an animation that makes the node "Enemy" move to the right by
|
||||||
# 100 pixels in 0.5 seconds.
|
# 100 pixels in 2.0 seconds.
|
||||||
var animation = Animation.new()
|
var animation = Animation.new()
|
||||||
var track_index = animation.add_track(Animation.TYPE_VALUE)
|
var track_index = animation.add_track(Animation.TYPE_VALUE)
|
||||||
animation.track_set_path(track_index, "Enemy:position:x")
|
animation.track_set_path(track_index, "Enemy:position:x")
|
||||||
animation.track_insert_key(track_index, 0.0, 0)
|
animation.track_insert_key(track_index, 0.0, 0)
|
||||||
animation.track_insert_key(track_index, 0.5, 100)
|
animation.track_insert_key(track_index, 2.0, 100)
|
||||||
|
animation.length = 2.0
|
||||||
[/gdscript]
|
[/gdscript]
|
||||||
[csharp]
|
[csharp]
|
||||||
// This creates an animation that makes the node "Enemy" move to the right by
|
// This creates an animation that makes the node "Enemy" move to the right by
|
||||||
// 100 pixels in 0.5 seconds.
|
// 100 pixels in 2.0 seconds.
|
||||||
var animation = new Animation();
|
var animation = new Animation();
|
||||||
int trackIndex = animation.AddTrack(Animation.TrackType.Value);
|
int trackIndex = animation.AddTrack(Animation.TrackType.Value);
|
||||||
animation.TrackSetPath(trackIndex, "Enemy:position:x");
|
animation.TrackSetPath(trackIndex, "Enemy:position:x");
|
||||||
animation.TrackInsertKey(trackIndex, 0.0f, 0);
|
animation.TrackInsertKey(trackIndex, 0.0f, 0);
|
||||||
animation.TrackInsertKey(trackIndex, 0.5f, 100);
|
animation.TrackInsertKey(trackIndex, 2.0f, 100);
|
||||||
|
animation.Length = 2.0f;
|
||||||
[/csharp]
|
[/csharp]
|
||||||
[/codeblocks]
|
[/codeblocks]
|
||||||
Animations are just data containers, and must be added to nodes such as an [AnimationPlayer] to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check [enum TrackType] to see available types.
|
Animations are just data containers, and must be added to nodes such as an [AnimationPlayer] to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check [enum TrackType] to see available types.
|
||||||
|
|
Loading…
Add table
Reference in a new issue