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

时间:2015-09-16 18:33:26

标签: lua storyboard composer-php

我的故事板场景相互转换,我的作曲家场景也是如此。但是,当我想要一个故事板场景转换到作曲家场景时,屏幕会变暗,事情就会停止。 场景一 - 故事板:

     ---------------------------------------- 
     -- 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没有出现在屏幕上。 我会非常感谢任何建议。

1 个答案:

答案 0 :(得分:1)

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

如果您希望应用程序正常运行,则必须始终使用一个场景管理器。

我推荐Composer。