How to get screen size to center pause menu

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By carlos21
:warning: Old Version Published before Godot 3 was released.

I’m having a bit of a problem with making sure that the pause menu ends up at the middle of the screen no matter where my character moves to. I have a rigidbody2d node with a camera2d attached to him so that it follows my character around. In that i grab that camera from my pause menu script and call the function get_camera_screen_center() to set the position of my pause menu but that function does not center my pause menu it is off center more to the right and bottom of the screen. The camera does have an offset but even when i set the offset to 0,0 it still does not center the pause menu.

Any help with this issue would be appreciated. Here is a bit of code that should center the pause menu to the screen.

func _input(event):
if(Input.is_action_pressed("pause")):
	set_pos(Vector2(spacemanCam.get_camera_screen_center()))
	show()
	get_tree().set_pause(true)
:bust_in_silhouette: Reply From: kocholes

I think you need to place your pause menu into a CanvasLayer. CanvasLayers are independent of tree order, and they only depend on their layer number.
With this, you don’t need to worry about the camera position.

That did the trick thank you.

carlos21 | 2016-03-10 13:43