故事板场景如何过渡到作曲家场景?



我的故事板场景相互过渡,我的作曲家场景也是如此。但当我想从故事板场景过渡到作曲家场景时,屏幕变暗,一切都停止了。第一幕-故事板:

     ---------------------------------------- 
     -- firstBar1.lua
     ----------------------------------------
    local storyboard = require "storyboard"
    local scene = storyboard.newScene()
    function scene:createScene(event) 
    local screenGroup = self.view
    local widget = require "widget"
    local function onFirstBar2BtnRelease()
            storyboard.gotoScene("firstBar2", "fade", 40)
            return true     
    end
    image1 = "images/staveBlankgrey2.png" -- the only button necessary
    local firstBar2Btn = widget.newButton{
            defaultFile = image1,
            width = 480, height = 320,
            onRelease = onFirstBar2BtnRelease
    } 
            screenGroup:insert(firstBar2Btn) 
   -- clef24
    image2 = display.newImageRect("images/clef24C.png", 100, 118)
    image2.x = display.contentWidth
    image2.y = display.contentHeight
    image2.x, image2.y = 62, 149
    screenGroup:insert(image2)
     -- workout count
    image3 = display.newImageRect("images/ex1of4.png", 60, 30)
    image3.x = display.contentWidth
    image3.y = display.contentHeight
    image3.x, image3.y = 32, 20
    screenGroup:insert(image3)
     -- note1
    image4 = display.newImageRect("images/crUp.png", 40, 75)
    image4.x = display.contentWidth
    image4.y = display.contentHeight
    image4.x, image4.y = 170, 167
    screenGroup:insert(image4)
     -- note2
    image5 = display.newImageRect("images/crDown.png", 40, 75)
    image5.x = display.contentWidth
    image5.y = display.contentHeight
    image5.x, image5.y = 320, 142
    screenGroup:insert(image5)
    end
    scene:addEventListener("createScene", scene)
    return scene

第二幕-作曲家:

     -----------------------------------------------
     -- firstBar2.lua
     -----------------------------------------------
    local composer = require ( "composer" )
    local scene = composer.newScene()
            local function showEvenBars()
                    local options = {
                            effect = "slideLeft",
                            time = 30,
                    }
            composer.gotoScene( "evenBars", options )
            end
     -- create scene
    function scene:createScene ( event )
    local sceneGroup = self.view
    end     

代码运行到这里。

    function scene:show( event )
    local sceneGroup = self.view
    local phase = event.phase
            if ( phase == "will") then
                    local background = display.newImage("images/staveBlankgrey2.png", 240, 160)
                    note1 =  display.newImage( "images/crUp.png", 130, 187)
                    note2 =  display.newImage( "images/crUp.png", 320, 187)
                    sceneGroup:insert( background )
                    sceneGroup:insert( note1 )
                    sceneGroup:insert( note2 )
            elseif ( phase == "did") then                                                   
                timer.performWithDelay(tempo, showEvenBars)
            end
    end
    function scene:hide( event )
          local sceneGroup = self.view
          local phase = event.phase
    end
    function scene:destroy( event )
          local sceneGroup = self.view
    end
    scene:addEventListener( "create", scene)
    scene:addEventListener( "show", scene)
    scene:addEventListener( "hide", scene)
    scene:addEventListener( "destroy", scene)
    return scene

第二个场景,firstBar2 lua没有出现在屏幕上。如有任何建议,我将不胜感激。

在故事板和作曲家场景之间切换是不可能的,因为它们是不同的库,所以它们的结构是不同的。

如果你想让你的应用正常运行,你必须总是使用一个场景管理器。

我推荐Composer

相关内容

  • 没有找到相关文章

最新更新