Documentation
¶
Overview ¶
PropertyTweener is used to interpolate a property in an object. See Tween.TweenProperty for more usage information.
The tweener will finish automatically if the target object is freed.
Note: Tween.TweenProperty is the only correct way to create PropertyTweener. Any PropertyTweener created manually will not function correctly.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPropertyTweener() Instance
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsRelative() Instance
- func (self Instance) AsTweener() Tweener.Instance
- func (self Instance) From(value any) Instance
- func (self Instance) FromCurrent() Instance
- func (self Instance) ID() ID
- func (self Instance) SetCustomInterpolator(interpolator_method func(Float.X) Float.X) Instance
- 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]) AsPropertyTweener ¶
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.PropertyTweener
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, obj Object.Instance, property string, final_val any, duration Float.X) Instance
Creates and appends a [PropertyTweener]. This method tweens a [param property] of an [param object] between an initial value and [param final_val] in a span of time equal to [param duration], in seconds. The initial value by default is the property's value at the time the tweening of the [PropertyTweener] starts. [codeblocks] [gdscript] var tween = create_tween() tween.tween_property($Sprite, "position", Vector2(100, 200), 1.0) tween.tween_property($Sprite, "position", Vector2(200, 300), 1.0) [/gdscript] [csharp] Tween tween = CreateTween(); tween.TweenProperty(GetNode("Sprite"), "position", new Vector2(100.0f, 200.0f), 1.0f); tween.TweenProperty(GetNode("Sprite"), "position", new Vector2(200.0f, 300.0f), 1.0f); [/csharp] [/codeblocks] 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. [b]Example:[/b] Moving an object twice from the same position, with different transition types: [codeblocks] [gdscript] var tween = create_tween() tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1.0).as_relative().set_trans(Tween.TRANS_SINE) tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1.0).as_relative().from_current().set_trans(Tween.TRANS_EXPO) [/gdscript] [csharp] Tween tween = CreateTween(); tween.TweenProperty(GetNode("Sprite"), "position", Vector2.Right * 300.0f, 1.0f).AsRelative().SetTrans(Tween.TransitionType.Sine); tween.TweenProperty(GetNode("Sprite"), "position", Vector2.Right * 300.0f, 1.0f).AsRelative().FromCurrent().SetTrans(Tween.TransitionType.Expo); [/csharp] [/codeblocks]
func (Instance) AsPropertyTweener ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsRelative ¶
When called, the final value will be used as a relative value instead.
Example: Move the node by 100 pixels to the right.
var tween = SceneTree.Get(node).CreateTween() PropertyTweener.Make(tween, self, "position", Vector2.MulX(Vector2.Right, 100), 1).AsRelative()
func (Instance) From ¶
Sets a custom initial value to the PropertyTweener.
Example: Move the node from position (100, 100) to (200, 100).
var tween = SceneTree.Get(node).CreateTween() PropertyTweener.Make(tween, self, "position", Vector2.New(200, 100), 1).From(Vector2.New(100, 100))
func (Instance) FromCurrent ¶
Makes the PropertyTweener use the current property value (i.e. at the time of creating this PropertyTweener) as a starting point. This is equivalent of using From with the current value. These two calls will do the same:
PropertyTweener.Make(tween, self, "position", Vector2.New(200, 100), 1).From(node2d.Position()) PropertyTweener.Make(tween, self, "position", Vector2.New(200, 100), 1).FromCurrent()
func (Instance) SetCustomInterpolator ¶
Allows interpolating the value with a custom easing function. The provided 'interpolator_method' will be called with a value ranging from 0.0 to 1.0 and is expected to return a value within the same range (values outside the range can be used for overshoot). The return value of the method is then used for interpolation between initial and final value. Note that the parameter passed to the method is still subject to the tweener's own easing.
var curve Curve.Instance var tween Tween.Instance PropertyTweener.Make(tween, self, "position:x", 300, 1).AsRelative().SetCustomInterpolator(func(v float32) float32 { return curve.SampleBaked(v) })
func (Instance) SetDelay ¶
Sets the time in seconds after which the PropertyTweener 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.