Tweening
This commit is contained in:
parent
80907c4067
commit
e3ebcc9975
2 changed files with 29 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
A UI nodes' opacity is modified via the modulate property which controls the tinting of the node.
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
Tweens are created using a nodes' create_tween() method
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
func slide_in() -> void:
|
||||||
|
var tween := create_tween()
|
||||||
|
tween.set_trans(Tween.TRANS_QUART)
|
||||||
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
|
````
|
||||||
|
|
||||||
|
Running tweens in parallel via parallel method.
|
||||||
|
Modulate controls tinting, subproperty a is for alpha, meaning a target visibilty of 100%
|
||||||
|
```python
|
||||||
|
tween.parallel().tween_property(body, "modulate:a", 1.0, 0.2)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Full tween method:
|
||||||
|
```python
|
||||||
|
func slide_in() -> void:
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.set_trans(Tween.TRANS_QUART)
|
||||||
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
|
body.position.x = 200.0
|
||||||
|
tween.tween_property(body, "position:x", 0.0, 1.0) # Move x from 200 to 0
|
||||||
|
body.modulate.a = 0.0 # UI node visibility = 0
|
||||||
|
tween.parallel().tween_property(body, "modulate:a", 1.0, 1.0) # Animate visibility towards 100% (a=alpha)
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue