Hi,
I am trying to get a pause menu to appear when a user presses Esc and then disappears when they press it again. I am currently making use of the z-coordinates to make it appear when the user presses Esc by giving it a greater z-coordinate than anything else on the screen to make it appear above it, this still doesn’t work, but is there a way to make the pause screen spawn and despawn when the user presses Esc, rather than leaving it spawned in constantly and only seen when the user wants it?
--Initialises the local variables for player input command
local HASH_PAUSE = hash("pause_game")
function init(self)
--Makes Defold listen to input action in the script
msg.post(".", "acquire_input_focus")
--Initialises Starting position
go.set_position(vmath.vector3(514, 314, 0))
end
function on_input(self, action_id, action)
--When the player presses Esc, the z-coordinate increases by 2
if action_id == HASH_PAUSE then
if action.pressed then
go.set_position(vmath.vector3(514, 314, 2))
--When the player presses Esc again, the z-coordinate decreases by 2
if action_id == HASH_PAUSE then
if action.pressed then
go.set_position(vmath.vector3(514, 314, 0))
end
end
end
end
end