summaryrefslogtreecommitdiff
path: root/doc/classes/Tween.xml
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2022-08-26 16:21:45 +0200
committerRaul Santos <raulsntos@gmail.com>2023-01-23 16:45:37 +0100
commit92e4b4e8881154636b2c05e2cf7383f503f73bba (patch)
treeb15048afe7f03a0c7896b19123430608c1be9ae8 /doc/classes/Tween.xml
parent1f22c482e192ef7df57fdc182243459d3dc4f232 (diff)
Update C# signal documentation and remove bind array
- Updates C# signal documentation and code examples to the new API in 4.0 - Replace all `nameof` usages with the exposed `StringName`
Diffstat (limited to 'doc/classes/Tween.xml')
-rw-r--r--doc/classes/Tween.xml20
1 files changed, 10 insertions, 10 deletions
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index fc0dd9f05d..9bb92cf362 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -19,7 +19,7 @@
Tween tween = GetTree().CreateTween();
tween.TweenProperty(GetNode("Sprite"), "modulate", Colors.Red, 1.0f);
tween.TweenProperty(GetNode("Sprite"), "scale", Vector2.Zero, 1.0f);
- tween.TweenCallback(new Callable(GetNode("Sprite").QueueFree));
+ tween.TweenCallback(Callable.From(GetNode("Sprite").QueueFree));
[/csharp]
[/codeblocks]
This sequence will make the [code]$Sprite[/code] node turn red, then shrink, before finally calling [method Node.queue_free] to free the sprite. [Tweener]s are executed one after another by default. This behavior can be changed using [method parallel] and [method set_parallel].
@@ -35,7 +35,7 @@
Tween tween = GetTree().CreateTween();
tween.TweenProperty(GetNode("Sprite"), "modulate", Colors.Red, 1.0f).SetTrans(Tween.TransitionType.Sine);
tween.TweenProperty(GetNode("Sprite"), "scale", Vector2.Zero, 1.0f).SetTrans(Tween.TransitionType.Bounce);
- tween.TweenCallback(new Callable(GetNode("Sprite").QueueFree));
+ tween.TweenCallback(Callable.From(GetNode("Sprite").QueueFree));
[/csharp]
[/codeblocks]
Most of the [Tween] methods can be chained this way too. In the following example the [Tween] is bound to the running script's node and a default transition is set for its [Tweener]s:
@@ -50,7 +50,7 @@
var tween = GetTree().CreateTween().BindNode(this).SetTrans(Tween.TransitionType.Elastic);
tween.TweenProperty(GetNode("Sprite"), "modulate", Colors.Red, 1.0f);
tween.TweenProperty(GetNode("Sprite"), "scale", Vector2.Zero, 1.0f);
- tween.TweenCallback(new Callable(GetNode("Sprite").QueueFree));
+ tween.TweenCallback(Callable.From(GetNode("Sprite").QueueFree));
[/csharp]
[/codeblocks]
Another interesting use for [Tween]s is animating arbitrary sets of objects:
@@ -281,7 +281,7 @@
[/gdscript]
[csharp]
Tween tween = GetTree().CreateTween().SetLoops();
- tween.TweenCallback(new Callable(Shoot)).SetDelay(1.0f);
+ tween.TweenCallback(Callable.From(Shoot)).SetDelay(1.0f);
[/csharp]
[/codeblocks]
[b]Example:[/b] Turning a sprite red and then blue, with 2 second delay:
@@ -294,8 +294,8 @@
[csharp]
Tween tween = GetTree().CreateTween();
Sprite2D sprite = GetNode&lt;Sprite2D&gt;("Sprite");
- tween.TweenCallback(new Callable(() =&gt; sprite.Modulate = Colors.Red)).SetDelay(2.0f);
- tween.TweenCallback(new Callable(() =&gt; sprite.Modulate = Colors.Blue)).SetDelay(2.0f);
+ tween.TweenCallback(Callable.From(() =&gt; sprite.Modulate = Colors.Red)).SetDelay(2.0f);
+ tween.TweenCallback(Callable.From(() =&gt; sprite.Modulate = Colors.Blue)).SetDelay(2.0f);
[/csharp]
[/codeblocks]
</description>
@@ -332,10 +332,10 @@
[csharp]
Tween tween = CreateTween().SetLoops();
tween.TweenProperty(GetNode("Sprite"), "position:x", 200.0f, 1.0f).AsRelative();
- tween.TweenCallback(new Callable(Jump));
+ tween.TweenCallback(Callable.From(Jump));
tween.TweenInterval(2.0f);
tween.TweenProperty(GetNode("Sprite"), "position:x", -200.0f, 1.0f).AsRelative();
- tween.TweenCallback(new Callable(Jump));
+ tween.TweenCallback(Callable.From(Jump));
tween.TweenInterval(2.0f);
[/csharp]
[/codeblocks]
@@ -357,7 +357,7 @@
[/gdscript]
[csharp]
Tween tween = CreateTween();
- tween.TweenMethod(new Callable(() =&gt; LookAt(Vector3.Up)), new Vector3(-1.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, -1.0f), 1.0f); // The LookAt() method takes up vector as second argument.
+ tween.TweenMethod(Callable.From(() =&gt; LookAt(Vector3.Up)), new Vector3(-1.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, -1.0f), 1.0f); // The LookAt() method takes up vector as second argument.
[/csharp]
[/codeblocks]
[b]Example:[/b] Setting the text of a [Label], using an intermediate method and after a delay:
@@ -376,7 +376,7 @@
base._Ready();
Tween tween = CreateTween();
- tween.TweenMethod(new Callable(SetLabelText), 0.0f, 10.0f, 1.0f).SetDelay(1.0f);
+ tween.TweenMethod(Callable.From&lt;int&gt;(SetLabelText), 0.0f, 10.0f, 1.0f).SetDelay(1.0f);
}
private void SetLabelText(int value)