好的。所以我正在编写一个 Corona 程序,并且在书中我按照所有说明创建了一个菜单并创建了一个新的游戏场景。问题是当我将代码放入模拟器或 bluestacks android 并按下图片时没有任何反应。从字面上看没有,与帮助按钮相同。
我做错了什么?这是我的代码:
function loadGame(event)
if event.target.name == "playbutton" then
transition.to(menuScreenGroup, {time = 0, alpha=0, onComplete = addGamescreen})
playBtn:removeEventListener("tap", loadgame)
end
end
function loadHelp(event)
if event.target.name == "helpbutton" then
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}
for row = 0, numOfRows - 1 do
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}
for row = 0, numOfRows - 1 do
for column = 0, numOfColumns - 1 do
-- Create a 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