Documentation
¶
Overview ¶
MethodTweener is similar to a combination of CallbackTweener and PropertyTweener. It calls a method providing an interpolated value as a parameter. See Tween.TweenMethod for more usage information.
The tweener will finish automatically if the callback's target object is freed.
Note: Tween.TweenMethod is the only correct way to create MethodTweener. Any MethodTweener created manually will not function correctly.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsMethodTweener() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsTweener() Tweener.Instance
- func (self Instance) ID() ID
- func (self Instance) SetDelay(delay Float.X) Instance
- func (self Instance) SetEase(ease Tween.EaseType) Instance
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetTrans(trans Tween.TransitionType) Instance
- func (self Instance) Virtual(name string) reflect.Value
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 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]) AsMethodTweener ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
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.MethodTweener
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 Make ¶
func Make(peer Tween.Instance, method Callable.Function, from any, to any, duration Float.X) Instance
Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [param from] and [param to] over the time specified by [param duration], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening. [b]Example:[/b] Making a 3D object look from one point to another point: [codeblocks] [gdscript] var tween = create_tween() tween.tween_method(look_at.bind(Vector3.UP), Vector3(-1, 0, -1), Vector3(1, 0, -1), 1.0) # The look_at() method takes up vector as second argument. [/gdscript] [csharp] Tween tween = CreateTween(); tween.TweenMethod(Callable.From((Vector3 target) => LookAt(target, Vector3.Up)), new Vector3(-1.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, -1.0f), 1.0f); // Use lambdas to bind additional arguments for the call. [/csharp] [/codeblocks] [b]Example:[/b] Setting the text of a [Label], using an intermediate method and after a delay: [codeblocks] [gdscript] func _ready():
var tween = create_tween() tween.tween_method(set_label_text, 0, 10, 1.0).set_delay(1.0)
func set_label_text(value: int):
$Label.text = "Counting " + str(value)
[/gdscript] [csharp] public override void _Ready()
{ base._Ready(); Tween tween = CreateTween(); tween.TweenMethod(Callable.From<int>(SetLabelText), 0.0f, 10.0f, 1.0f).SetDelay(1.0f); }
private void SetLabelText(int value)
{ GetNode<Label>("Label").Text = $"Counting {value}"; }
[/csharp] [/codeblocks]
func (Instance) AsMethodTweener ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) SetDelay ¶
Sets the time in seconds after which the MethodTweener will start interpolating. By default there's no delay.
func (Instance) SetEase ¶
Sets the type of used easing from [Tween.EaseType]. If not set, the default easing is used from the Tween that contains this Tweener.