Hi, i’m trying to make a mobile game with a gui for “pause” and other menu setting…
I want that when the player touch the button “pause” on the right corner the game pause but everywhere else if he touch the screen the menu “pause” don’t open but only the character jump ? Sorry if what i mean isn’t not really clear
In our examples section you can find a gui button example which demonstrates the two scenarios: clicking a button, and clicking outside a button which seems to be what you need in your case.
I believe this example is a good start for what you are doing. And feel free to ask more questions if anything is unclear or if you need more help with the code!
The final else statement will be run every time you get input that isn’t matched by the conditionals above. The indentation is wrong and that might be what is confusing you?
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
local button = gui.get_node("pause")
if gui.pick_node(button, action.x, action.y) and self.pause == false then
self.pause = true
msg.post("#gameproxy", "set_time_step", {factor = 0, mode = 1})
else
self.pause = false
msg.post("#gameproxy", "set_time_step", {factor = 1, mode = 1})
end
elseif action_id == hash("escape") and action.released and self.pause == false then
self.pause = true
msg.post("#gameproxy", "set_time_step", {factor = 0, mode = 1})
elseif action_id == hash("escape") and action.released and self.pause == true then
self.pause = false
msg.post("#gameproxy", "set_time_step", {factor = 1, mode = 1})
end
end
but now when i try build my project i have an error message :
java.lang.AssertionError: Assert failed: Cycle detected on node type editor.collection/CollectionNode and output :build-targets
(not (contains? (:in-production ctx) [node-id label]))
Hmm, it seems like you might have a collection referencing itself. Did you change the #gameproxy by any chance? Please feel free to share the project with me (bjorn.ritzl@king.com) and I can take a look.
In the collection field of my gameproxy i have referenced the “level1. collection” and the gameproxy is in this collection… I now have change that and put the gameproxy and hud object in the main.collection but now when i build the game and pause, all of the level duplicate itself and 1 is mooving and the other no
Hey thanks for the help, i have done what you tell me, but now i have 2 more problems :
when i try the game on my smartphone (Honor 8 on android 7.0) the game don’t do anything when i touch the screen…
when i’m in the game it first load the controller.collection who load then the level1.collection but when i’m into this collection i can’t go back in the controller.collection or load the menu.collection
I saw that you have multi-touch bound in your game input bindings. Have you set up your input to actually handle multi touch? It’s a bit different from single touch in the way the touch points are sent in the action in on_input. If you only need single touch then my recommendation is to remove the multi-touch binding and instead set a binding on MOUSE_BUTTON_1 and bind that to action touch. This will translate to single touch on mobile.
Yes thank you now it’s work on my smartphone but have you any idea for the problem to load the menu.collection when i’m in the level1.collection ? In the console it show me this : ERROR:GAMEOBJECT: Instance ‘/controller’ could not be found when dispatching message ‘show_menu’ sent from level1:/InGame#gui