Hi there, I have been struggling to get this work for a hour now
How do I get the center co-ordinates of the window at all times ?
I want to bring up the pause menu like the resume button and the main menu button while the timescale of the game is 0.
I want to get them both at the center of the screen one below the other.
I tired windowheight/2 and windowwidth/2 for the said buttons but that
doesn't work because that will give it a definite position.
I want to get these buttons created in the center of the window on esc down, irrespective of the player position on the layout.
I also have a doubt about. When a new layout is loaded is the other layout still running in the background.
And is there anyway if i could just keep everything the same when esc button down go to a new "pause" layout and then when clicked on resume in the "pause" layout the game beigns from where it stopped??
To get the center position of the viewport use 'ScrollX' and 'ScrollY'.
Edit: Use parallax as mentioned below if it suits your needs
I will set a layer to parallax 0,0 for interface~
If I need to create a fantastic menu~
I will set more layers into parallax 0,0~
I think no, a new layout is like a new page~
Everything refreshed except global variable~
To bring up a pause menu, make a new layer and set the parallax to 0,0. Parallax determines how fast or slow the layer scrolls relative to the others; 100,100 is normal, 150,150 is 1.5 times faster, 50,50 is half as slow, and 0,0 means it won't move at all. Which means no matter where you are in the level, the pause menu will ALWAYS be in the center of the screen.
As for loading new layouts and then trying to go back to the previous one... yeahhh, don't even try. You'd have to manually save the state of the layout before leaving it and then manually reset it once you go back. Pause menus can be inside the regular layout, just invisible; when the player pauses, make the menu visible. No need to switch layouts.
Thank you AkiraWong,SullyTheStrange,Nimtrix !!
It worked :)
Develop games in your browser. Powerful, performant & highly capable.
I am using the pin behavior and then it follows my center object eg. player