Tutorial Help - I can't move texts 'Get Ready' and 'Game over' in Dodge the Creeps

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sbjung1214

I’ve been following the tutorial for the first game making.

I’ve gotten everything else to work except this one things: I can’t make the texts “Get Ready” and “Game over” to appear at the center of the game screen once the player hits mobs. Instead, the said two texts are shifted to the right, partly off the screen.
I’ve compared my project to the completed project here Releases · kidscancode/Godot3_dodge · GitHub but i simply can not figure out what I’ve missed.

Here are my scripts
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")
	$StartButton.show()
	$MessageLabel.text = "Dodge \nthe \nCreeps!"
	$MessageLabel.show()
		
	yield(get_tree().create_timer(1), "timeout")
		
	

func update_score(score):
		$ScoreLabel.text = str(score)
		
func _on_StartButton_pressed():
	$StartButton.hide()
	emit_signal("start_game")
	
func _on_MessageTimer_timeout():
	$MessageLabel.hide() 
 

Player:

extends Area2D

signal hit

export var speed = 400
var screen_size
# Declare member variables here. Examples:
# var a = 2
# var b = "text"

################################################################################
# Called when the node enters the scene tree for the first time.
func _ready():
	hide()
	screen_size = get_viewport_rect().size
	
func start(pos):
	position = pos
	show()
	$CollisionShape2D.disabled = false
	
func _process(delta):
	var velocity = Vector2()
	if Input.is_action_pressed("ui_right"):
		velocity.x +=1
	if Input.is_action_pressed("ui_left"):
		velocity.x -=1
	if Input.is_action_pressed("ui_up"):
		velocity.y -=1
	if Input.is_action_pressed("ui_down"):
		velocity.y +=1
	if velocity.length() > 0:
		velocity = velocity.normalized() * speed
		$AnimatedSprite.play()
	else:
		$AnimatedSprite.stop()
		
	if velocity.x !=0:
		$AnimatedSprite.animation = "right"
		$AnimatedSprite.flip_h = velocity.x < 0
		$AnimatedSprite.flip_v = false
	elif velocity.y !=0:
		$AnimatedSprite.animation = "up"
		$AnimatedSprite.flip_h = false
		$AnimatedSprite.flip_v = velocity.y > 0
	
	position +=velocity * delta #limits boundary collisions
	position.x = clamp(position.x, 30, screen_size.x -30)
	position.y = clamp(position.y, 30, screen_size.y -30)
	#######################################################################
	
func _on_Player_body_entered(body):
	hide() #hide player after collision
	emit_signal("hit")
	$CollisionShape2D.set_deferred("disabled", true)
	

######Player########################################################################

######Enemies####################################################################

Main:

extends Node

export (PackedScene) var Mob
var score


func _ready():
	randomize()

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass

func new_game():
	score = 0
	$HUD.update_score(score)
	$Player.start($StartPosition.position)
	$StartTimer.start()
	$HUD.show_message("Get Ready")
	
	pass # Replace with function body.
	
func game_over():
	$ScoreTimer.stop()
	$MobTimer.stop()
	$HUD.show_game_over()

func _on_MobTimer_timeout():
	$MobPath/MobSpawn.offset = randi()
	var mob = Mob.instance()
	add_child(mob)
	var direction = $MobPath/MobSpawn.rotation + PI / 2
	mob.position = $MobPath/MobSpawn.position
	direction += rand_range( -PI / 4, PI / 4)
	mob.rotation = direction
	mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
	mob.linear_velocity = mob.linear_velocity.rotated(direction)
	$HUD.connect("start_game", mob, "_on_start_game")

func _on_ScoreTimer_timeout():
	score += 1
	$HUD.update_score(score)

func _on_StartTimer_timeout():
	$MobTimer.start()
	$ScoreTimer.start()
:bust_in_silhouette: Reply From: njamster

Your code looks fine. I’d guess the problem is with the properties set / not set for the “MessageLabel”-node. Instead of looking at the scripts, you should look at the scene, specifically this section. Did you set the label’s layout to “HCenter Wide” and align to “Center”? Note that you’ll have to do this again if you changed the window size after you set it for the first time. It’s simpy a shortcut to easily set all of the anchor- and margin-properties at once, they won’t be updated afterwards though.