Lua: Problems with menu -
ok. coding corona program, , in book have followed instructions create menu , create new game scene. problem nothing happens when put code emulator or bluestacks android , press on pictures nothing happens. literally nothing, same button.
what have done wrong? code:
function loadgame(event) if event.target.name == "playbutton" transition.to(menuscreengroup, {time = 0, alpha=0, oncomplete = addgamescreen}) playbtn:removeeventlistener("tap", loadgame) end end function loadhelp(event) if event.target.name == "helpbutton" transition.to(menuscreengroup, {time = 0, alpha=0, oncomplete = addhelpscreen}) helpbtn:removeeventlistener("tap", loadhelp) end end function addhelpscreen() helpscreengroup = display.newgroup() helpscreen = display.newimage("helpscreen.png", 0, 0, true) helpscreen.x = _w helpscreen.y = _h end function addgamescreen() background = display.newimage("bg.png", 0, 0, true) background.x = _w background.y = _ys paddle = display.newimage("paddle.png") paddle.x = 160; paddle.y = 460; paddle.name = "paddle" ball = display.newimage("ball.png") ball.x = 160; ball.y = 460; ball.name = "ball" scoretext = display.newtext("score:", 5, 2, "arial", 14) scoretext:settextcolor( 255, 255, 255, 255) scorenum = display.newtext("0", 54, 2, "arial", 14) scorenum:settextcolor( 255, 255, 255, 255) leveltext = display.newtext("level:", 420, 2, "arial", 14) leveltext:settextcolor(255, 255, 255, 255) levelnum = display.newtext("1", 460, 2, "arial", 14) levelnum:settextcolor( 255, 255, 255, 255) gamelevel1() currentlevel = 1 bricks:tofront() local numofrows = 4 local numofcolumns = 4 local brickplacement = {x = (_w) - (brickwidth * numofcolumns ) / 2 + 20, y = 50} row = 0, numofrows - 1 local brick = display.newimage("brick.png") brick.name = "brick" brick.x = brickplacement.x + (column * brickwidth) brick.y = brickplacement.y + (row * brickheight) physics.addbody(brick, "static", {density = 1, friction = 0, bounce = 0}) bricks.insert(bricks, brick) end end function gamelevel2() currentlevel = 2 bricks:tofront() local numofrows = 5 local numofcolumns = 8 local brickplacement = {x = (_w) - (brickwidth * numofcolumns ) / 2 + 20, y = 50} row = 0, numofrows - 1 column = 0, numofcolumns - 1 -- create brick local brick = display.newimage("brick.png") brick.name = "brick" brick.x = brickplacement.x + (column * brickwidth) brick.y = brickplacement.y + (row * brickheight) physics.addbody(brick, "static", {density = 1, friction = 0, bounce = 0}) bricks.insert(bricks, brick) end end end
check line of code:
background.y = _ys
i think should be:
background.y = _h
Comments
Post a Comment