Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rayu |
func _ready() -> void:
$ScoreCount.text = str(Globals.Score)
set_process(true)
spawn_Player1(1)
for i in range(4 + Globals.Score):
spawn_Enemy1()
func spawn_Player1(num):
for i1 in range(num):
var p1 = player1.instance()
p1.connect("Player1_pressed", self, "_on_Player1_pressed")
Player_container1.add_child(p1)
func _on_Player1_pressed():
if Globals.timeLeft > 0:
Globals.timeLeft += 5
if Globals.timeLeft > Globals.maxTime:
Globals.timeLeft = Globals.maxTime
Globals.Score += 1
get_tree().change_scene("res://Game.tscn")
func spawn_Enemy1():
var rand1 = floor(rand_range(0, Enemy1.size()))
var piece1 = Enemy1[rand1].instance()
add_child(piece1)
This is my Main Scene Code.
I want that when the on_Player1 pressed event happens that the Scene doesn’t start right away, it should wait like 2 seconds before load to the next Scene (i tried some things with the Timer Node). And if the on_Player1 pressed event happends and the Waittime is set, i want it that the Player Freezes and Enemies are not visible for the duration of the Waittime. And it should not register Score more than 1 time for each Scene.
Thank you in advance for AndyCampbell and jgodfrey i still wait for the Random Functions solution, i sent the code on a comment there.