Ok。だから私はコロナプログラムをコーディングしています.本では、メニューを作成し、新しいゲームシーンを作成するためのすべての指示に従いました. 問題は、コードをエミュレーターまたはブルースタックアンドロイドに入れても何も起こらず、写真を押しても何も起こらないことです。文字通り何もありません。ヘルプ ボタンと同じです。
私は何を間違えましたか?これは私のコードです:
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