Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
please help me check my RangPreview code in godot 4 xccdsI try to tranlate RangPreview code to godot 4.2 version script. here I use a global tween varable.I am not sure it is right or wrong. it there any improvement advise?
```gdscript
extends Sprite2D
@export var radius := 100.0
@export var tween_duration := 0.5
@onready var tween :Tween
func appear() -> void:
var ratio = radius / texture.get_width()
var final_scale = Vector2(ratio, ratio)*2
if tween and tween.is_running():
tween.stop()
tween = create_tween()
tween.set_parallel(true)
tween.tween_property(self, "scale", final_scale, tween_duration)
tween.tween_property(self, "modulate", Color(1,1,1,1), tween_duration)
func disappear() -> void:
if tween and tween.is_running():
tween.stop()
tween = create_tween()
tween.set_parallel(true)
tween.tween_property(self, "scale", Vector2.ZERO, tween_duration)
tween.tween_property(self, "modulate", Color(1,1,1,0), tween_duration)
```
10Aug. 14, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.