Godot Version
Godot 4
Question
Im trying to create an effect where when the person clicks the button, a blood spatter image pops up and gradually fades back down to being invisible. Im new to godot so be nice to me lol. Any idea where to go from here
extends Button
@export var normal_scale: Vector2 = Vector2(1, 1)
@export var hover_scale: Vector2 = Vector2(1.1, 1.1)
@export var duration: float = 0.5
var tween: Tween
var blood_spatter_tween: Tween
func _ready() -> void:
pivot_offset = size / 2
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
pressed.connect(_on_pressed)
func _on_mouse_entered() -> void:
if tween:
tween.kill()
tween = create_tween()
tween.tween_property(self, "scale", hover_scale, duration).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
$Hover_Sound_Story.play()
await $Hover_Sound_Story.finished
func _on_mouse_exited() -> void:
if tween:
tween.kill()
tween = create_tween()
tween.tween_property(self, "scale", normal_scale, duration).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
func _on_pressed() -> void:
if tween:
tween.kill()
tween = create_tween()
blood_spatter_tween = create_tween()
blood_spatter_tween.tween_property($TextureRect,"modulate:a",0,2.0)
$Click_Sound_Story.play()
$Click_Sound_Story_2.play()
await $Click_Sound_Story.finished
await $Click_Sound_Story_2.finished
func _on_button_2_pressed() -> void:
$Click_Sound_Story.play()
$Click_Sound_Story_2.play()
await $Click_Sound_Story.finished
await $Click_Sound_Story_2.finished
func _on_button_3_pressed() -> void:
$Click_Sound_Story.play()
$Click_Sound_Story_2.play()
await $Click_Sound_Story.finished
await $Click_Sound_Story_2.finished
func _on_character_lore_pressed() -> void:
get_tree().change_scene_to_file("res://Character_Bio_Select_Screen.tscn")
pass # Replace with function body.
