2012-03-29 46 views
0

我正在主菜單中創建一個彈出窗口。在彈出窗口中執行closePopUp(),並顯示消息'無法更改彈出窗口內的場景'。幫助解決問題彈出窗口(導演)。 Corona SDK

+0

嗨Bakunov,可以顯示一些你的'closePopUp的()'代碼,以便我們可以幫助你呢? – cctan 2012-03-30 01:20:05

回答

0

closePopUp

function OnClickExitNo(event) 
     print("click"); 
     if event.phase == "ended" then 
      director:closePopUp(); 
     end 
    end 

    exitNo = ui.newButton{ 
    default = "src/img/exitNo.png", 
    over = "src/img/exitNo.png", 
    onEvent = OnClickExitNo 
    } 

和openPopUp

director:openPopUp("exit_screen", popClosed); 
-1

試試這個.... ü應放置director.lua文件在項目文件夾

main.lua

local director=require("director") 
local mainGroup=display.newGroup() 

function clean(event) 
print("clean") 
end 

function main() 
display.setStatusBar(display.HiddenStatusBar) 
mainGroup:insert(director.directorView) 
director:changeScene("screen1") 
end 

main() 

screen1.lua

module(...,package.seeall) 

function clean(event) 
print("clean") 
end 

new =function() 
local localGroup=display.newGroup() 
local circle=display.newCircle(display.contentWidth/2,display.contentHeight/2,80) 
circle:setFillColor(220,25,220) 
local text=display.newText("click to openPopUp", 0, 0, native.systemFontBold, 16) 
text.x=circle.x 
text.y=circle.y 
localGroup:insert(circle) 

local listener=function(event) 
if(event.phase=="ended")then 
    director:openPopUp("screen2","flip") 
end 
    end 

circle:addEventListener("touch",listener) 
return localGroup; 
end 

enter image description here


screen2.lua

module(...,package.seeall) 
function clean(event) 
print("clean") 
    end 

new =function(prams) 
local localGroup=display.newGroup() 
local circle =display.newCircle(display.contentWidth/2,display.contentHeight/2,100) 
circle:setFillColor(255,0,0) 

local text=display.newText("click to closePopUp", 0, 0, native.systemFontBold, 16) 
text.x=circle.x 
text.y=circle.y 

    local listener=function(event) 
if(event.phase=="ended")then 
    circle:removeSelf() 
    text:removeSelf() 
    director:closePopUp() 
end 

    end 

circle:addEventListener("touch",listener) 
localGroup:insert(circle) 
return localGroup; 
    end 

enter image description here