wondering if anyone could help me out with this?
https://www.youtube.com/watch?v=Pb8b2IdofG4
Thanks!
wondering if anyone could help me out with this?
https://www.youtube.com/watch?v=Pb8b2IdofG4
Thanks!
You will need to post some code. The video really doesn’t give any one an opportunity to read your code. Please use the <> button in the bar above to copy and paste your code into your reply. Provide the right amount of code. Not all of it, but don’t leave out relevant parts either.
Rob
local composer = require("composer") local scene = composer.newScene() function scene:create(e) local brownGradientFill = { type = "gradient", color1 = { 150/255, 150/255, 150/255, 1 }, color2 = { 1, 1, 1, 1 }, direction = "down" } bg = display.newRect(0,0,\_SCREEN.WIDTH, \_SCREEN.HEIGHT) bg.x = \_SCREEN.CENTER.x bg.y = \_SCREEN.CENTER.y bg.fill = brownGradientFill local font = "Consolas" or system.nativeFont or "AmericanTypewriter" level1 = display.newImageRect("playrect.png",110,110) level1.x = \_SCREEN.CENTER.x - 185 level1.y = \_SCREEN.CENTER.y - 105 level1text = display.newText ("1",0,0, font, 80) level1text.x = \_SCREEN.CENTER.x - 185 level1text.y = \_SCREEN.CENTER.y - 115 level1text.fill = { 1, 1, 1 } level2 = display.newImageRect("playrect.png",110,110) level2.x = \_SCREEN.CENTER.x - 62 level2.y = \_SCREEN.CENTER.y - 105 level2text = display.newText ("2",0,0, font, 80) level2text.x = \_SCREEN.CENTER.x - 62 level2text.y = \_SCREEN.CENTER.y - 115 level2text.fill = { 1, 1, 1 } level3 = display.newImageRect("playrect.png",110,110) level3.x = \_SCREEN.CENTER.x + 62 level3.y = \_SCREEN.CENTER.y - 105 level3text = display.newText ("3",0,0, font, 80) level3text.x = \_SCREEN.CENTER.x + 62 level3text.y = \_SCREEN.CENTER.y - 115 level3text.fill = { 1, 1, 1 } level4 = display.newImageRect("playrect.png",110,110) level4.x = \_SCREEN.CENTER.x + 187 level4.y = \_SCREEN.CENTER.y - 105 level4text = display.newText ("4",0,0, font, 80) level4text.x = \_SCREEN.CENTER.x + 187 level4text.y = \_SCREEN.CENTER.y - 115 level4text.fill = { 1, 1, 1 } level5 = display.newImageRect("playrect.png",110,110) level5.x = \_SCREEN.CENTER.x - 185 level5.y = \_SCREEN.CENTER.y + 10 level5text = display.newText ("5",0,0, font, 80) level5text.x = \_SCREEN.CENTER.x - 185 level5text.y = \_SCREEN.CENTER.y + 10 level5text.fill = { 1, 1, 1 } level6 = display.newImageRect("playrect.png",110,110) level6.x = \_SCREEN.CENTER.x - 62 level6.y = \_SCREEN.CENTER.y + 10 level6text = display.newText ("6",0,0, font, 80) level6text.x = \_SCREEN.CENTER.x - 62 level6text.y = \_SCREEN.CENTER.y +10 level6text.fill = { 1, 1, 1 } level7 = display.newImageRect("playrect.png",110,110) level7.x = \_SCREEN.CENTER.x + 62 level7.y = \_SCREEN.CENTER.y + 10 level7text = display.newText ("7",0,0, font, 80) level7text.x = \_SCREEN.CENTER.x + 62 level7text.y = \_SCREEN.CENTER.y + 10 level7text.fill = { 1, 1, 1 } level8 = display.newImageRect("playrect.png",110,110) level8.x = \_SCREEN.CENTER.x + 187 level8.y = \_SCREEN.CENTER.y + 10 level8text = display.newText ("8",0,0, font, 80) level8text.x = \_SCREEN.CENTER.x + 187 level8text.y = \_SCREEN.CENTER.y + 10 level8text.fill = { 1, 1, 1 } rightarrow = display.newImageRect("rightarrow.png",200,110) rightarrow.x = \_SCREEN.CENTER.x + 130 rightarrow.y = \_SCREEN.CENTER.y + 110 hblevelselect = display.newImageRect("playrect.png",75,75) hblevelselect.x = \_SCREEN.CENTER.x - 175 hblevelselect.y = \_SCREEN.CENTER.y + 110 hblevelselecttext = display.newText ("Home",0,0, font, 25) hblevelselecttext.x = \_SCREEN.CENTER.x - 175 hblevelselecttext.y = \_SCREEN.CENTER.y + 110 hblevelselecttext.fill = { 1, 1, 1 } end function scene:show(e) if(e.phase == "will") then function rightarrow:tap(e) composer.gotoScene("levelselect2") end rightarrow:addEventListener("tap", rightarrow) end end function scene:hide(e) if(e.phase == "will") then composer.removeScene("levelselect") end end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) return scene
Here is my code for the levelselect screen thanks for the help Rob!
Couple of things…you are creating all these objects and never adding them to the scene’s view group. Composer won’t be able to manage these objects. Secondly they are global, not local to the scene. Therefore if you use the same names in other modules you’re going to stomp on yourself.
Next I don’t see where you are ever adding a tap or touch listener to the buttons. Each button needs to have an assigned event handler and a function to manage it.
You might want to read over this tutorial:
https://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/
Rob
Thanks for the feedback! How do you add the objects to the scenes view group? Also at the moment I only have the right arrow added for the tap event. I tried adding the others in the scene.show as a tap event and kept getting errors.
So I guess really i’m just wondering where do I need to put the event listeners and the tap functions in the page?
group:insert(object) after you create object.
For the other question you probably only need one function, just add an .id value or .name value to each object that defines the scene it should go to or id the level some how. Then do a object:addEventListener(“tap”, yourTapFunction) for each button. The tutorial I suggested should show you a way to do this in a loop to reduce the amount of code you’re writing.
Rob
Thank you so much! How would I rewrite the new function with the .id or .name. Will this also allow me to have the objects go to different scenes?
level8.name = “level8”
Or whatever you need to identify the level
Rob
local composer = require("composer") local scene = composer.newScene() function scene:create(e) local brownGradientFill = { type = "gradient", color1 = { 150/255, 150/255, 150/255, 1 }, color2 = { 1, 1, 1, 1 }, direction = "down" } bg = display.newRect(0,0,\_SCREEN.WIDTH, \_SCREEN.HEIGHT) bg.x = \_SCREEN.CENTER.x bg.y = \_SCREEN.CENTER.y bg.fill = brownGradientFill local font = "Consolas" or system.nativeFont or "AmericanTypewriter" level1 = display.newImageRect("playrect.png",110,110) level1.x = \_SCREEN.CENTER.x - 185 level1.y = \_SCREEN.CENTER.y - 105 level1text = display.newText ("1",0,0, font, 80) level1text.x = \_SCREEN.CENTER.x - 185 level1text.y = \_SCREEN.CENTER.y - 115 level1text.fill = { 1, 1, 1 } level2 = display.newImageRect("playrect.png",110,110) level2.x = \_SCREEN.CENTER.x - 62 level2.y = \_SCREEN.CENTER.y - 105 level2text = display.newText ("2",0,0, font, 80) level2text.x = \_SCREEN.CENTER.x - 62 level2text.y = \_SCREEN.CENTER.y - 115 level2text.fill = { 1, 1, 1 } level3 = display.newImageRect("playrect.png",110,110) level3.x = \_SCREEN.CENTER.x + 62 level3.y = \_SCREEN.CENTER.y - 105 level3text = display.newText ("3",0,0, font, 80) level3text.x = \_SCREEN.CENTER.x + 62 level3text.y = \_SCREEN.CENTER.y - 115 level3text.fill = { 1, 1, 1 } level4 = display.newImageRect("playrect.png",110,110) level4.x = \_SCREEN.CENTER.x + 187 level4.y = \_SCREEN.CENTER.y - 105 level4text = display.newText ("4",0,0, font, 80) level4text.x = \_SCREEN.CENTER.x + 187 level4text.y = \_SCREEN.CENTER.y - 115 level4text.fill = { 1, 1, 1 } level5 = display.newImageRect("playrect.png",110,110) level5.x = \_SCREEN.CENTER.x - 185 level5.y = \_SCREEN.CENTER.y + 10 level5text = display.newText ("5",0,0, font, 80) level5text.x = \_SCREEN.CENTER.x - 185 level5text.y = \_SCREEN.CENTER.y + 10 level5text.fill = { 1, 1, 1 } level6 = display.newImageRect("playrect.png",110,110) level6.x = \_SCREEN.CENTER.x - 62 level6.y = \_SCREEN.CENTER.y + 10 level6text = display.newText ("6",0,0, font, 80) level6text.x = \_SCREEN.CENTER.x - 62 level6text.y = \_SCREEN.CENTER.y +10 level6text.fill = { 1, 1, 1 } level7 = display.newImageRect("playrect.png",110,110) level7.x = \_SCREEN.CENTER.x + 62 level7.y = \_SCREEN.CENTER.y + 10 level7text = display.newText ("7",0,0, font, 80) level7text.x = \_SCREEN.CENTER.x + 62 level7text.y = \_SCREEN.CENTER.y + 10 level7text.fill = { 1, 1, 1 } level8 = display.newImageRect("playrect.png",110,110) level8.x = \_SCREEN.CENTER.x + 187 level8.y = \_SCREEN.CENTER.y + 10 level8text = display.newText ("8",0,0, font, 80) level8text.x = \_SCREEN.CENTER.x + 187 level8text.y = \_SCREEN.CENTER.y + 10 level8text.fill = { 1, 1, 1 } rightarrow = display.newImageRect("rightarrow.png",200,110) rightarrow.x = \_SCREEN.CENTER.x + 130 rightarrow.y = \_SCREEN.CENTER.y + 110 hblevelselect = display.newImageRect("playrect.png",75,75) hblevelselect.x = \_SCREEN.CENTER.x - 175 hblevelselect.y = \_SCREEN.CENTER.y + 110 hblevelselecttext = display.newText ("Home",0,0, font, 25) hblevelselecttext.x = \_SCREEN.CENTER.x - 175 hblevelselecttext.y = \_SCREEN.CENTER.y + 110 hblevelselecttext.fill = { 1, 1, 1 } end function scene:show(e) if(e.phase == "will") then function rightarrow:tap(e) composer.gotoScene("levelselect2") end function hblevelselect:tap(e) composer.gotoScene("mainscreen") end rightarrow:addEventListener("tap", rightarrow) hblevelselect:addEventListener("tap", hblevelselect) end end function scene:hide(e) if(e.phase == "will") then composer.removeScene("levelselect") end end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) return scene
Hey thank you for keeping with me and sorry for asking all of the questions I know it is probably annoying you but for some reason I am super stumped I tried those things you suggested and still can’t figure it out I add the hblevelselect to the scene.show and it still does the same thing. What should I do to make this work. (Again very sorry, i’m just super confused)
roaminggamer, the link has a 404 error. could you try it again please?
Updated above.
Note: Links often get corrupted when posted to forums, but you can always grab the part after http(s):// and re-paste it.
Meanwhile, I’ll try to remember to test my links. I seem to do that a lot.

You will need to post some code. The video really doesn’t give any one an opportunity to read your code. Please use the <> button in the bar above to copy and paste your code into your reply. Provide the right amount of code. Not all of it, but don’t leave out relevant parts either.
Rob
local composer = require("composer") local scene = composer.newScene() function scene:create(e) local brownGradientFill = { type = "gradient", color1 = { 150/255, 150/255, 150/255, 1 }, color2 = { 1, 1, 1, 1 }, direction = "down" } bg = display.newRect(0,0,\_SCREEN.WIDTH, \_SCREEN.HEIGHT) bg.x = \_SCREEN.CENTER.x bg.y = \_SCREEN.CENTER.y bg.fill = brownGradientFill local font = "Consolas" or system.nativeFont or "AmericanTypewriter" level1 = display.newImageRect("playrect.png",110,110) level1.x = \_SCREEN.CENTER.x - 185 level1.y = \_SCREEN.CENTER.y - 105 level1text = display.newText ("1",0,0, font, 80) level1text.x = \_SCREEN.CENTER.x - 185 level1text.y = \_SCREEN.CENTER.y - 115 level1text.fill = { 1, 1, 1 } level2 = display.newImageRect("playrect.png",110,110) level2.x = \_SCREEN.CENTER.x - 62 level2.y = \_SCREEN.CENTER.y - 105 level2text = display.newText ("2",0,0, font, 80) level2text.x = \_SCREEN.CENTER.x - 62 level2text.y = \_SCREEN.CENTER.y - 115 level2text.fill = { 1, 1, 1 } level3 = display.newImageRect("playrect.png",110,110) level3.x = \_SCREEN.CENTER.x + 62 level3.y = \_SCREEN.CENTER.y - 105 level3text = display.newText ("3",0,0, font, 80) level3text.x = \_SCREEN.CENTER.x + 62 level3text.y = \_SCREEN.CENTER.y - 115 level3text.fill = { 1, 1, 1 } level4 = display.newImageRect("playrect.png",110,110) level4.x = \_SCREEN.CENTER.x + 187 level4.y = \_SCREEN.CENTER.y - 105 level4text = display.newText ("4",0,0, font, 80) level4text.x = \_SCREEN.CENTER.x + 187 level4text.y = \_SCREEN.CENTER.y - 115 level4text.fill = { 1, 1, 1 } level5 = display.newImageRect("playrect.png",110,110) level5.x = \_SCREEN.CENTER.x - 185 level5.y = \_SCREEN.CENTER.y + 10 level5text = display.newText ("5",0,0, font, 80) level5text.x = \_SCREEN.CENTER.x - 185 level5text.y = \_SCREEN.CENTER.y + 10 level5text.fill = { 1, 1, 1 } level6 = display.newImageRect("playrect.png",110,110) level6.x = \_SCREEN.CENTER.x - 62 level6.y = \_SCREEN.CENTER.y + 10 level6text = display.newText ("6",0,0, font, 80) level6text.x = \_SCREEN.CENTER.x - 62 level6text.y = \_SCREEN.CENTER.y +10 level6text.fill = { 1, 1, 1 } level7 = display.newImageRect("playrect.png",110,110) level7.x = \_SCREEN.CENTER.x + 62 level7.y = \_SCREEN.CENTER.y + 10 level7text = display.newText ("7",0,0, font, 80) level7text.x = \_SCREEN.CENTER.x + 62 level7text.y = \_SCREEN.CENTER.y + 10 level7text.fill = { 1, 1, 1 } level8 = display.newImageRect("playrect.png",110,110) level8.x = \_SCREEN.CENTER.x + 187 level8.y = \_SCREEN.CENTER.y + 10 level8text = display.newText ("8",0,0, font, 80) level8text.x = \_SCREEN.CENTER.x + 187 level8text.y = \_SCREEN.CENTER.y + 10 level8text.fill = { 1, 1, 1 } rightarrow = display.newImageRect("rightarrow.png",200,110) rightarrow.x = \_SCREEN.CENTER.x + 130 rightarrow.y = \_SCREEN.CENTER.y + 110 hblevelselect = display.newImageRect("playrect.png",75,75) hblevelselect.x = \_SCREEN.CENTER.x - 175 hblevelselect.y = \_SCREEN.CENTER.y + 110 hblevelselecttext = display.newText ("Home",0,0, font, 25) hblevelselecttext.x = \_SCREEN.CENTER.x - 175 hblevelselecttext.y = \_SCREEN.CENTER.y + 110 hblevelselecttext.fill = { 1, 1, 1 } end function scene:show(e) if(e.phase == "will") then function rightarrow:tap(e) composer.gotoScene("levelselect2") end rightarrow:addEventListener("tap", rightarrow) end end function scene:hide(e) if(e.phase == "will") then composer.removeScene("levelselect") end end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) return scene
Here is my code for the levelselect screen thanks for the help Rob!
Couple of things…you are creating all these objects and never adding them to the scene’s view group. Composer won’t be able to manage these objects. Secondly they are global, not local to the scene. Therefore if you use the same names in other modules you’re going to stomp on yourself.
Next I don’t see where you are ever adding a tap or touch listener to the buttons. Each button needs to have an assigned event handler and a function to manage it.
You might want to read over this tutorial:
https://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/
Rob
Thanks for the feedback! How do you add the objects to the scenes view group? Also at the moment I only have the right arrow added for the tap event. I tried adding the others in the scene.show as a tap event and kept getting errors.
So I guess really i’m just wondering where do I need to put the event listeners and the tap functions in the page?
group:insert(object) after you create object.
For the other question you probably only need one function, just add an .id value or .name value to each object that defines the scene it should go to or id the level some how. Then do a object:addEventListener(“tap”, yourTapFunction) for each button. The tutorial I suggested should show you a way to do this in a loop to reduce the amount of code you’re writing.
Rob
Thank you so much! How would I rewrite the new function with the .id or .name. Will this also allow me to have the objects go to different scenes?