diff options
Diffstat (limited to 'doc/classes/Tween.xml')
-rw-r--r-- | doc/classes/Tween.xml | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 72f32f39c2..f9ec0d115d 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -6,7 +6,7 @@ <description> Tweens are mostly useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them. [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween]; it would be difficult to do the same thing with an [AnimationPlayer] node. Tweens are also more light-weight than [AnimationPlayer], so they are very much suited for simple animations or general tasks that don't require visual tweaking provided by the editor. They can be used in a fire-and-forget manner for some logic that normally would be done by code. You can e.g. make something shoot periodically by using a looped [CallbackTweener] with a delay. - A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid. They can't be used for tweening values, but you can do manual interpolation with [method interpolate_value]. + A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid and can't be used for tweening values. A [Tween] animation is composed of a sequence of [Tweener]s, which by default are executed one after another. You can create a sequence by appending [Tweener]s to the [Tween]. Animating something with a [Tweener] is called tweening. Example tweening sequence looks like this: [codeblock] var tween = get_tree().create_tween() @@ -76,10 +76,10 @@ <return type="float" /> <description> Returns the total time in seconds the [Tween] has been animating (i.e. time since it started, not counting pauses etc.). The time is affected by [method set_speed_scale] and [method stop] will reset it to [code]0[/code]. - [b]Note:[/code] As it results from accumulating frame deltas, the time returned after the [Tween] has finished animating will be slightly greater than the actual [Tween] duration. + [b]Note:[/b] As it results from accumulating frame deltas, the time returned after the [Tween] has finished animating will be slightly greater than the actual [Tween] duration. </description> </method> - <method name="interpolate_value"> + <method name="interpolate_value" qualifiers="static"> <return type="Variant" /> <argument index="0" name="initial_value" type="Variant" /> <argument index="1" name="delta_value" type="Variant" /> @@ -105,7 +105,7 @@ <method name="is_valid"> <return type="bool" /> <description> - Returns whether the [Tween] is valid. A valid [Tween] is a [Tween] contained by the scene tree (i.e. the array from [method SceneTree.get_processed_tweens] will contain this [Tween]). [Tween] might become invalid when it has finished tweening or was killed, also when created with [code]Tween.new()[/code]. Invalid [Tween] can't have [Tweener]s appended, because it can't animate them. You can however still use [method interpolate_value]. + Returns whether the [Tween] is valid. A valid [Tween] is a [Tween] contained by the scene tree (i.e. the array from [method SceneTree.get_processed_tweens] will contain this [Tween]). [Tween] might become invalid when it has finished tweening or was killed, also when created with [code]Tween.new()[/code]. Invalid [Tween] can't have [Tweener]s appended, because it can't animate them. </description> </method> <method name="kill"> @@ -231,10 +231,10 @@ Example: creating an object that moves back and forth and jumps every few seconds. [codeblock] var tween = create_tween().set_loops() - tween.tween_property("position:x", 200, 1).as_relative() + tween.tween_property($Sprite, "position:x", 200.0, 1).as_relative() tween.tween_callback(jump) tween.tween_interval(2) - tween.tween_property("position:x", -200, 1).as_relative() + tween.tween_property($Sprite, "position:x", -200.0, 1).as_relative() tween.tween_callback(jump) tween.tween_interval(2) [/codeblock] @@ -274,16 +274,16 @@ Creates and appends a [PropertyTweener]. This method tweens a [code]property[/code] of an [code]object[/code] between an initial value and [code]final_val[/code] in a span of time equal to [code]duration[/code], in seconds. The initial value by default is a value at the time the tweening of the [PropertyTweener] start. For example: [codeblock] var tween = create_tween() - tween.tween_property($Sprite, "position", Vector2(100, 200) - tween.tween_property($Sprite, "position", Vector2(200, 300) + tween.tween_property($Sprite, "position", Vector2(100, 200), 1) + tween.tween_property($Sprite, "position", Vector2(200, 300), 1) [/codeblock] will move the sprite to position (100, 200) and then to (200, 300). If you use [method PropertyTweener.from] or [method PropertyTweener.from_current], the starting position will be overwritten by the given value instead. See other methods in [PropertyTweener] to see how the tweening can be tweaked further. [b]Note:[/b] You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (eg. [code]position:x[/code]), where it would only apply to that particular component. Example: moving object twice from the same position, with different transition types. [codeblock] var tween = create_tween() - tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().set_trans(Tween.TRANS_SINE) - tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().from_current().set_trans(Tween.TRANS_EXPO) + tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().set_trans(Tween.TRANS_SINE) + tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().from_current().set_trans(Tween.TRANS_EXPO) [/codeblock] </description> </method> |