obsidian/MyObsidianVault/Godot/2D/Tutorial M7 - Telling a story/M7.L11 - Animate Sophia sliding in/Tweens.md
2024-12-22 12:24:50 +01:00

820 B

Tweens are created using a nodes' create_tween() method

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%

tween.parallel().tween_property(body, "modulate:a", 1.0, 0.2)

Full tween method:

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)