Android Corona SDK Composer不工作,但也没有给我任何错误

Android Corona SDK Composer不工作,但也没有给我任何错误,android,lua,coronasdk,corona-storyboard,Android,Lua,Coronasdk,Corona Storyboard,我做了一个小游戏,一切都很好,但我决定是时候添加一个开始菜单,以使游戏更好看。我曾尝试使用Composer进行场景管理,但到目前为止,我还没有成功。我没有通过电晕终端得到任何错误,但我也没有在模拟器上看到任何东西,我只是得到一个黑屏 这是密码 local composer = require( "composer" ) local scene = composer.newScene() -- --------------------------------------------------

我做了一个小游戏,一切都很好,但我决定是时候添加一个开始菜单,以使游戏更好看。我曾尝试使用Composer进行场景管理,但到目前为止,我还没有成功。我没有通过电晕终端得到任何错误,但我也没有在模拟器上看到任何东西,我只是得到一个黑屏

这是密码

local composer = require( "composer" )

local scene = composer.newScene()

-- -----------------------------------------------------------------------------------------------------------------
-- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called.
-- -----------------------------------------------------------------------------------------------------------------

-- local forward references should go here

-- -------------------------------------------------------------------------------


-- "scene:create()"
function scene:create( event )

    local sceneGroup = self.view
    -- Initialize the scene here.
    -- Example: add display objects to "sceneGroup", add touch listeners, etc.
    --Image Assets
stoneGroup = display.newGroup()
    local bg = display.newImageRect("images/GameBackground.png",display.viewableContentHeight*2,display.viewableContentWidth*2)
    bg.x= display.viewableContentWidth/2
    bg.y = display.viewableContentHeight/2
    bg.anchorX = 0.5
    bg.anchorY = 0.5
    physics = require("physics")
    physics.start()
    physics.setDrawMode( "normal" )
    sceneGroup:insert(bg)

    local bg2 = display.newImageRect("images/GameBackground.png",display.viewableContentHeight*2,display.viewableContentWidth*2)
    bg2.x= display.viewableContentWidth*4
    bg2.y = display.viewableContentHeight/2
    bg2.anchorX = 0.5
    bg2.anchorY = 0.5
    sceneGroup:insert(bg2)

    local ground = display.newRect(display.viewableContentWidth/2,display.viewableContentHeight-84,display.viewableContentWidth*3.5, 65)
    ground.anchorX = 0.5
    ground.anchorY = 0.5
    ground:setFillColor(0,0,0)
    physics.addBody( ground, "static", { density=3.0, friction=0.5, bounce=0.1} )
    sceneGroup:insert(ground)

    local ghost = display.newImageRect("images/Ghost.png", 83,55)
    ghost.y = display.viewableContentHeight-170
    physics.addBody( ghost, "dynamic", { density=3, friction=5.5, bounce=.3 } )
    ghost.isFixedRotation = true
    sceneGroup:insert(ghost)

    local stoned = {"images/Bones_Gravestone_nograss.png", "images/Skull_Gravestone_nograss.png", "images/Web_Gravestone_nograss.png"}

--Stones
        local stone1 = display.newImageRect(stoned[math.random(1,3)], 50,50)
        stone1.x = display.viewableContentWidth * 2.2
        stone1.anchorX = 0.5
        stone1.anchorY = 0.5
        stone1.y = (ground.y - stone1.height-3)
        sceneGroup:insert(stone1)

        local stone2 = display.newImageRect(stoned[math.random(1,3)], 50,50)
        stone2.x = display.viewableContentWidth * 3.2
        stone2.anchorX = 0.5
        stone2.anchorY = 0.5
        stone2.y = (ground.y - stone2.height-3)
        sceneGroup:insert(stone2)

        local stone3 = display.newImageRect(stoned[math.random(1,3)], 50,50)
        stone3.x = display.viewableContentWidth * 5.2
        stone3.anchorX = 0.5
        stone3.anchorY = 0.5
        stone3.y = (ground.y - stone2.height-3)
        sceneGroup:insert(stone3)

        local stone4 = display.newImageRect(stoned[math.random(1,3)], 50,50)
        stone4.x = display.viewableContentWidth * 7.2
        stone4.anchorX = 0.5
        stone4.anchorY = 0.5
        stone4.y = (ground.y - stone2.height-3)
        sceneGroup:insert(stone4)

        local stone5 = display.newImageRect(stoned[math.random(1,3)], 50,50)
        stone5.x = display.viewableContentWidth * 8.5
        stone5.anchorX = 0.5
        stone5.anchorY = 0.5
        stone5.y = (ground.y - stone2.height-3)
        sceneGroup:insert(stone5)

--Grass
    local grass = display.newImageRect("images/Grass.png", display.viewableContentWidth*5, 200)
    grass.anchorX = .5
    grass.y = (display.viewableContentHeight - 171)
    sceneGroup:insert(grass)

--Wall Left
    local leftWall = display.newRect(display.viewableContentWidth-display.viewableContentWidth*2.13, 200,100,display.viewableContentHeight)
    physics.addBody(leftWall,"kinematic", { density=10, friction=10, bounce=5 } )
    leftWall.alpha=0
    sceneGroup:insert(leftWall)

    local rightWall = display.newRect(display.viewableContentWidth*2.13, 200,100,display.viewableContentHeight)
    physics.addBody(rightWall,"kinematic", { density=10, friction=10, bounce=5 } )
    rightWall.alpha=0
    sceneGroup:insert(rightWall)

--Coin
    local coin = display.newImageRect("images/Coin.png", 45, 45)
    coin.x = display.viewableContentWidth*2.5
    coin.y = 350
    physics.addBody( coin, "kinematic", { density=0, friction=0, bounce=0 } )
    sceneGroup:insert(coin)

    local coin2 = display.newImageRect("images/Coin.png", 45, 45)
    coin2.x = coin.x*2.5
    coin2.y = 350
    physics.addBody( coin2, "kinematic", { density=0, friction=0, bounce=0 } )
    sceneGroup:insert(coin2)

    --Score
    scoreNum = tonumber(0)
    local score = display.newText(scoreNum, 0, 0, native.systemFont, 32)
    score.anchorX = .5
    score.anchorY = .5
    score.x = display.viewableContentWidth*1.92
    score.y = 50
    sceneGroup:insert(score)
    --scoreIcon
    local scoreIcon = display.newImageRect("images/Coin.png", 45, 45)
    scoreIcon.y = score.y-2
    scoreIcon.x = score.x - 50
    sceneGroup:insert(scoreIcon)

    -- Listener Functions
--Scrolls bg
function scrollBG(self, event)
    if self.x < -(display.viewableContentWidth*3) then
        self.x = display.viewableContentWidth*4
    else
        self.x = self.x - 3
    end
end

function scrollBG2(self, event)
    if self.x < -(display.viewableContentWidth*3) then
        self.x = display.viewableContentWidth*4
    else
        self.x = self.x - 3
    end
end
-- Jump Function
function jump(event)
    if event.phase == "began" and ghost.y >=  (display.viewableContentHeight-200) then
        ghost:applyForce(200, -4500, ghost.x, ghost.y)
    end
    return true
end

--Scroll Tomb Stone
function scrollStone(self, event)
    if self.x < -(display.viewableContentWidth*3) then
        self.x = display.viewableContentWidth*math.random(2,5)
    else
        self.x = self.x - 5
    end
end

--Scroll Coin
function scrollCoin(self, event)
    if self.x < -(display.viewableContentWidth*3) then
        self.x = display.viewableContentWidth*math.random(2,5)
        self.y = math.random(300, 400)
        physics.addBody(coin, "kinematic", { density=0, friction=0, bounce=0 })
        transition.to(coin, {time=300, alpha=100, width=45, height=45})

    else
        self.x = self.x - 5
    end
end

--Scroll Coin
function scrollCoin2(self, event)
    if self.x < -(display.viewableContentWidth*3) then
        self.x = display.viewableContentWidth*math.random(2,5)
        self.y = math.random(300, 400)
        physics.addBody(coin2,"kinematic", { density=0, friction=0, bounce=0 })
        transition.to(coin2, {time=300, alpha=100, width=45, height=45})

    else
        self.x = self.x - 5
    end
end
    local function removeTheBody()
        physics.removeBody(coin)
    end

    local function removeTheBody2()
        physics.removeBody(coin2)
    end
--Coin Collision
local function onCoinCollision( self, event )
    transition.to(coin, {time=300, alpha=0, width=10, height=30})
    scoreNum = scoreNum+1
    score.text = scoreNum
    timer.performWithDelay( 1, removeTheBody )

end

local function onCoin2Collision( self, event )
    transition.to(coin2, {time=300, alpha=0, width=10, height=30})
    scoreNum = scoreNum+1
    score.text = scoreNum
    timer.performWithDelay( 1, removeTheBody2 )
end





--Stone Physics
physics.addBody( stone1, "static", { density=3, friction=5.5, bounce=.3 } )
physics.addBody( stone2, "static", { density=3, friction=5.5, bounce=.3 } )
physics.addBody( stone3, "static", { density=3, friction=5.5, bounce=.3 } )
physics.addBody( stone4, "static", { density=3, friction=5.5, bounce=.3 } )
physics.addBody( stone5, "static", { density=3, friction=5.5, bounce=.3 } )

end


-- "scene:show()"
function scene:show( event )

    local sceneGroup = self.view
    local phase = event.phase

    if ( phase == "will" ) then
        -- Called when the scene is still off screen (but is about to come on screen).
    elseif ( phase == "did" ) then
        --Tomb Stoned
--Event Listeners
bg.enterFrame=scrollBG
Runtime:addEventListener("enterFrame", bg)
bg2.enterFrame=scrollBG2
Runtime:addEventListener("enterFrame", bg2)

stone1.enterFrame=scrollStone
Runtime:addEventListener("enterFrame", stone1)

stone2.enterFrame=scrollStone
Runtime:addEventListener("enterFrame", stone2)

stone3.enterFrame=scrollStone
Runtime:addEventListener("enterFrame", stone3)

stone4.enterFrame=scrollStone
Runtime:addEventListener("enterFrame", stone4)

stone5.enterFrame=scrollStone
Runtime:addEventListener("enterFrame", stone5)

--Ghost Listener
Runtime:addEventListener("touch", jump)

--Coin Move
coin.enterFrame=scrollCoin
Runtime:addEventListener("enterFrame", coin)

coin.collision=onCoinCollision
coin:addEventListener("collision", coin)

--Coin Move
coin2.enterFrame=scrollCoin2
Runtime:addEventListener("enterFrame", coin2)

coin2.collision=onCoin2Collision
coin2:addEventListener("collision", coin2)
        -- Called when the scene is now on screen.
        -- Insert code here to make the scene come alive.
        -- Example: start timers, begin animation, play audio, etc.
    end
end


-- "scene:hide()"
function scene:hide( event )

    local sceneGroup = self.view
    local phase = event.phase

    if ( phase == "will" ) then
        -- Called when the scene is on screen (but is about to go off screen).
        -- Insert code here to "pause" the scene.
        -- Example: stop timers, stop animation, stop audio, etc.
    elseif ( phase == "did" ) then
        -- Called immediately after scene goes off screen.
    end
end


-- "scene:destroy()"
function scene:destroy( event )

    local sceneGroup = self.view

    -- Called prior to the removal of scene's view ("sceneGroup").
    -- Insert code here to clean up the scene.
    -- Example: remove display objects, save state, etc.
end


-- -------------------------------------------------------------------------------

-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )

-- -------------------------------------------------------------------------------

return scene
localcomposer=require(“composer”)
本地场景=composer.newScene()
-- -----------------------------------------------------------------------------------------------------------------
--除非调用“composer.removese()”,否则侦听器函数之外的所有代码将只执行一次。
-- -----------------------------------------------------------------------------------------------------------------
--本地转发参考应该在这里
-- -------------------------------------------------------------------------------
--“场景:创建()”
功能场景:创建(事件)
本地场景组=self.view
--在这里初始化场景。
--示例:将显示对象添加到“场景组”,添加触摸监听器等。
--形象资产
stoneGroup=display.newGroup()
local bg=display.newImageRect(“images/GameBackground.png”,display.viewableContentHeight*2,display.viewableContentWidth*2)
bg.x=display.viewableContentWidth/2
bg.y=display.viewableContentHeight/2
bg.anchorX=0.5
bg.anchorY=0.5
物理=要求(“物理”)
物理开始
物理。设置绘图模式(“正常”)
场景组:插入(背景)
local bg2=display.newImageRect(“images/GameBackground.png”,display.viewableContentHeight*2,display.viewableContentWidth*2)
bg2.x=display.viewableContentWidth*4
bg2.y=display.viewableContentHeight/2
bg2.anchorX=0.5
bg2.anchorY=0.5
场景组:插入(bg2)
本地地面=display.newRect(display.viewableContentWidth/2,display.viewableContentHeight-84,display.viewableContentWidth*3.5,65)
地锚=0.5
地锚=0.5
地面:setFillColor(0,0,0)
物理。addBody(地面,“静态”{密度=3.0,摩擦=0.5,反弹=0.1})
场景组:插入(接地)
本地ghost=display.newImageRect(“images/ghost.png”,83,55)
ghost.y=display.viewableContentHeight-170
物理.addBody(鬼,动态,{密度=3,摩擦=5.5,反弹=0.3})
ghost.isFixedRotation=true
场景组:插入(重影)
本地stoned={“images/Bones\u Gravestone\u nograss.png”、“images/Skull\u Gravestone\u nograss.png”、“images/Web\u Gravestone\u nograss.png”}
--石头
本地stone1=display.newImageRect(stoned[math.random(1,3)],50,50)
stone1.x=display.viewableContentWidth*2.2
stone1.anchorX=0.5
stone1.anchorY=0.5
stone1.y=(地面.y-stone1.height-3)
场景组:插入(1)
本地stone2=display.newImageRect(stoned[math.random(1,3)],50,50)
stone2.x=display.viewableContentWidth*3.2
stone2.anchorX=0.5
stone2.anchorY=0.5
stone2.y=(地面.y-stone2.height-3)
场景组:插入(2)
本地stone3=display.newImageRect(stoned[math.random(1,3)],50,50)
stone3.x=display.viewableContentWidth*5.2
stone3.anchorX=0.5
stone3.anchorY=0.5
stone3.y=(地面.y-stone2.height-3)
场景组:插入(stone3)
本地stone4=display.newImageRect(stoned[math.random(1,3)],50,50)
stone4.x=display.viewableContentWidth*7.2
stone4.anchorX=0.5
stone4.anchorY=0.5
stone4.y=(地面y-stone2.height-3)
场景组:插入(4)
本地stone5=display.newImageRect(stoned[math.random(1,3)],50,50)
stone5.x=display.viewableContentWidth*8.5
stone5.anchorX=0.5
stone5.anchorY=0.5
stone5.y=(地面y-stone2.height-3)
场景组:插入(5)
--草
本地grass=display.newImageRect(“images/grass.png”,display.viewableContentWidth*5200)
草锚=0.5
grass.y=(display.viewableContentHeight-171)
场景组:插入(草地)
--左墙
本地leftWall=display.newRect(display.viewableContentWidth display.viewableContentWidth*2.13200100,display.viewableContentHeight)
addBody(leftWall,“运动学”{密度=10,摩擦力=10,反弹=5})
leftWall.alpha=0
场景组:插入(左墙)
本地rightWall=display.newRect(display.viewableContentWidth*2.13200100,display.viewableContentHeight)
物理学.addBody(右墙,“运动学”{密度=10,摩擦力=10,反弹=5})
rightWall.alpha=0
场景组:插入(右墙)
--硬币
本地硬币=display.newImageRect(“images/coin.png”,45,45)
coin.x=display.viewableContentWidth*2.5
硬币y=350
addBody(硬币,运动学,{密度=0,摩擦力=0,反弹=0})
场景组:插入(硬币)
本地coin2=display.newImageRect(“images/Coin.png”,45,45)
coin2.x=coin.x*2.5
coin2.y=350
addBody(coin2,“运动学”{密度=0,摩擦力=0,反弹=0})
场景组:插入(2)
--得分
scoreNum=tonumber(0)
本地分数=display.newText(scoreNum,0,0,native.systemFont,32)
得分.主播=0.5
得分为0.5分
score.x=display.viewableContentWidth*1.92
得分y=50
场景组:插入(分数)
--记分图标
本地scoreIcon=display.newImageRect(“images/Coin.png”,45,45)
scoreIcon.y=score.y-2
scoreIcon.x=score.x-50
场景组:插入(scoreIcon)
--侦听器功能
--卷轴背景
函数滚动bg(自我、事件)
如果self.x<-(display.viewableContentWidth*3),则
self.x=display.viewableContentWidth*4
其他的
self.x=self.x-3
结束
结束
函数scrollBG2(自身、事件)
如果self.x<-(display.viewableContentWidth*3),则
self.x=display.viewableContentWidth*4
其他的