2015-09-16 100 views
0

我的故事板場景過渡到彼此,我的作曲家場景也如此。但是當我想要一個故事板場景轉換到作曲家場景時,屏幕變暗,事情就會停止。 場景一個 - 故事板:Lua - 故事板場景如何過渡到作曲家場景?

 ---------------------------------------- 
    -- 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

謝謝,這很重要。我一直在尋找作曲家版本的按鈕,以改變故事板,但我無法找到代碼的例子。我嘗試在最初的設置中用'composer'代替'storyboard',但那不起作用。我應該在哪裏看? – julianLE3

+0

Corona作曲家庫與故事板幾乎相似。 – user5331438

+0

你應該看看文檔。你會發現基本設置 – user5331438