Hello. I'm starting tutorial, and I have tried two times the Dodge the Creeps project. I have arrived at a point that I'm stuck, and I would like to ask If you can see were the problem is.
I have followed the tutorial instructions several times, I have corrected some errors and tried again. But the problem now is as it follows:
When the text Get Ready appears on the screen it does not start the mob spawning. I keep on that screen moving my character, with the Get Ready sign, so I think the problem is somwhere from HUD to Main scenes, because Player and Mob works correct individually. Maybe the signal that calls mob doesn't works properly, but I cannot figure why.
Here is my MAIN
extends Node
export (PackedScene) var Mob
var score
func _ready():
randomize()
func _on_MobTimer_timeout():
# Choose a random location on Path2D.
$MobPath/MobSpawnLocation.offset = randi()
# Create a Mob instance and add it to the scene.
var mob = Mob.instance()
add_child(mob)
# Set the mob's direction perpendicular to the path direction.
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
# Set the mob's position to a random location.
mob.position = $MobPath/MobSpawnLocation.position
# Add some randomness to the direction.
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
# Set the velocity (speed & direction).
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = mob.linear_velocity.rotated(direction)
func game_over():
$ScoreTimer.stop()
$MobTimer.stop()
$HUD.show_game_over()
func new_game():
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.update_score(score)
$HUD.show_message("Get Ready")
func _on_StartTimer_timeout():
$MobTimer.start()
$ScoreTimer.start()
func _on_ScoreTimer_timeout():
score += 1
$HUD.update_score(score)
And here's my HUD
extends CanvasLayer
signal start_game
func show_message(text):
$MessageLabel.text = text
$MessageLabel.show()
$MessageTimer.start()
func show_game_over ():
show_message("Game Over")
yield ($MessageTimer, "timeout")
$MessageLabel.text = "Dodge the \nCreeps"
$MessageTimer.show()
yield(get_tree().create_timer(1), "timeout")
$StartButton.show()
func update_score(score):
$ScoreLabel.text = str(score)
func _on_StartButton_button_down():
$StartButton.hide()
emit_signal("start_game")
func _onMessageTimer_timeout():
$MessageLabel.hide()
Thank you very much in advance.