Creating a Pause menu (solved)

I am trying to make a pause menu for my game that appears over the top of the game with the game still being visible in the background. But I just can’t seem to get it to work.
Pong v1.6.zip (284.9 KB)
Here is my project, if you guys could take a look it would be most apreciated.

Quite a few issues with your main.gui_script file. Have a look at the changes in the modified file below.

You’ll still need to set a pause flag or something so the game actually pauses when the pause menu is displayed.

main.gui_script

function init(self)
    msg.post(".", "acquire_input_focus")
    gui.set_enabled(gui.get_node("pausemenu"), false)
end

function on_input(self, action_id, action)
    if action_id == hash("p") and action.released then
        gui.set_enabled(gui.get_node("pausemenu"), true)
    end
    if action_id == hash("click") and action.released then
        local resume = gui.get_node("resume")
        if gui.pick_node(resume, action.x, action.y) then
            gui.set_enabled(gui.get_node("pausemenu"), false)
        end
        local leave = gui.get_node("leave")
        if gui.pick_node(leave, action.x, action.y) then
            gui.set_enabled(gui.get_node("pausemenu"), false)
            msg.post("proxy:/go#loader", "show_menu")
        end
    end
end
4 Likes

Thank you for your help, it now works perfectly.

2 Likes