Hello, could anyone help me in figuring out how to create a system, where the user taps on a button, and that characters’ image sheet is applied in a different scene.
If any code is needed, feel free to ask for it.
Hello, could anyone help me in figuring out how to create a system, where the user taps on a button, and that characters’ image sheet is applied in a different scene.
If any code is needed, feel free to ask for it.
I have tried this:
Menu.lua:
local function onPlayBtnRelease(event) if (event.phase == "ended" and event.target.id == "girlButton") then print(event.target.id) composer.gotoScene("level1") composer.setVariable("characterChosen", girlSprite) end if (event.phase == "ended" and event.target.id == "boyButton") then print(event.target.id) composer.gotoScene("level1") composer.setVariable("characterChosen", boySprite) end end
level1.lua:
character = composer.getVariable("characterChosen")
here you go
Sorry, but what do you mean by “here you go”? Just wondering.
hold on did not upload, my internet is not great at my current location
Thank you so much scottrules44, I am extremely grateful of your help, the code worked like a charm! You do rule.
lol
I have tried this:
Menu.lua:
local function onPlayBtnRelease(event) if (event.phase == "ended" and event.target.id == "girlButton") then print(event.target.id) composer.gotoScene("level1") composer.setVariable("characterChosen", girlSprite) end if (event.phase == "ended" and event.target.id == "boyButton") then print(event.target.id) composer.gotoScene("level1") composer.setVariable("characterChosen", boySprite) end end
level1.lua:
character = composer.getVariable("characterChosen")
here you go
Sorry, but what do you mean by “here you go”? Just wondering.
hold on did not upload, my internet is not great at my current location
Thank you so much scottrules44, I am extremely grateful of your help, the code worked like a charm! You do rule.
lol