36 lines
939 B
GDScript
36 lines
939 B
GDScript
extends Control
|
|
|
|
@onready var layar_gelap = $HitamTransparan
|
|
@onready var tombol_pause_utama = $TombolPause
|
|
# Tambahkan ini untuk mereferensikan Health Bar yang baru kamu buat
|
|
@onready var health_bar = $HealthBar
|
|
|
|
func _ready():
|
|
layar_gelap.hide()
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
# Inisialisasi awal agar bar penuh saat game mulai
|
|
if health_bar:
|
|
health_bar.value = 100
|
|
|
|
# --- FUNGSI UNTUK HEALTH BAR ---
|
|
# Fungsi ini yang akan dipanggil oleh Player atau Stage Manager nanti
|
|
func update_nyawa_player(hp_sekarang):
|
|
if health_bar:
|
|
health_bar.value = hp_sekarang
|
|
|
|
# --- LOGIKA PAUSE ---
|
|
func _on_tombol_pause_pressed():
|
|
get_tree().paused = true
|
|
layar_gelap.show()
|
|
tombol_pause_utama.hide()
|
|
|
|
func _on_tombol_lanjut_pressed():
|
|
get_tree().paused = false
|
|
layar_gelap.hide()
|
|
tombol_pause_utama.show()
|
|
|
|
func _on_tombol_kembali_pressed():
|
|
get_tree().paused = false
|
|
get_tree().change_scene_to_file("res://main_menu.tscn")
|