0

私はコロナSDKを使用するのが初めてで、メインメニューボタンに少し問題があります. ボタンを押すたびに、ビューが移動したり変更されたりしません。タイトル画面でボタンが消えるだけです。

module(..., package.seeall)

local ui = require ("ui")
local ui = require ("director")

local assetPath = "assets/"

local mainGroup = display.newGroup()

function new(params)
    local titleScreen = display.newImageRect(assetPath .. "Law of Magic.jpg", 
        display.contentWidth, display.contentHeight)
    titleScreen.x = display.contentWidth / 2
    titleScreen.y = 265
    mainGroup:insert(titleScreen)
    director:changeScene("titleScreen")

    local newgame = ui.newButton{ default = assetPath .. "new game.png", 
        onRelease = function(event)  director:changeScene("New game") end,}
    newgame.x = display.contentWidth / 2
    newgame.y = 445
    mainGroup:insert(newgame)

    local continue = ui.newButton{ default = assetPath .. "continue.png", 
        onRelease = function(event)  director:changeScene("Continue") end,}
    continue.x = display.contentWidth / 2
    continue.y = 447
    mainGroup:insert(continue)

    local option = ui.newButton{ default = assetPath .. "option.png", 
        onRelease = function(event)  director:changeScene("Option") end,}
    option.x = display.contentWidth / 2
    option.y = 449
    mainGroup:insert(option)

    local help = ui.newButton{ default = assetPath .. "help.png", 
        onRelease = function(event)  director:changeScene("Help") end,}
    help.x = display.contentWidth / 2
    help.y = 451
    mainGroup:insert(help)

    local exitgame = ui.newButton{ default = assetPath .. "exit game.png", 
        onRelease = function(event)  director:changeScene("Exit game") end,}
    exitgame.x = display.contentWidth / 2
    exitgame.y = 453
    mainGroup:insert(exitgame)

    return mainGroup
end
4

3 に答える 3

2

まず、ローカルUIを2回宣言しているのがわかります。

次に、ストーリーボードを使用する必要があります。これは、コロナでサポートされており、coronaSDkを初めて使用するためです。

于 2012-12-30T06:36:16.563 に答える
0

この行を変更

local ui = require ("director")

local director = require ("director")

そして、ファイル名が正しいことを確認してください。

于 2016-03-08T23:18:05.843 に答える
0

これについても: director:changeScene("New game")

シーンに移動しようとしています。シーン ファイルの名前を入力しています。この場合、次のファイルを探します。

ニューゲーム.lua

main.lua ファイルと同じフォルダーにあります。個人的には、スペースを含むファイル名は避けます。シミュレーターでは大文字と小文字が区別されませんが、デバイスでは大文字と小文字が区別されるため、ファイル名の大文字と小文字がコーディングしているものと一致することを確認する必要があります。

また、次の行も気になります: director:changeScene("titleScreen")

ボタンを設定する前に、シーンを変更しようとします。

于 2013-01-06T03:14:13.627 に答える