我如何解决电晕中的导演问题

时间:2013-01-09 09:49:29

标签: ios corona

local function connectedToServer(event)


    client:send("connected")
    cleanAll()

    function a()
        director:changeScene( "PlayerClient" )
    end
    timer.performWithDelay( 1000, a() ,1) 




end
Runtime:addEventListener("autolanConnected", connectedToServer)

这是我的代码行,其中有关于更改场景的问题director:changeScene( "PlayerClient" )  在第一场它运行正常但在第二轮比赛时我暂停比赛或在我赢或输后我回到菜单然后我再次开始比赛,那一行director:changeScene( "PlayerClient" )出错。有人能帮助我吗?

错误是

2013-01-09 14:51:25.871 Corona Simulator[478:707] Runtime error
    ...arooqi/Desktop/Crazy Candy 5 Jan 2013 5/director.lua:1060: attempt to call method 'insert' (a nil value)
stack traceback:
    [C]: in function 'insert'
    ...arooqi/Desktop/Crazy Candy 5 Jan 2013 5/director.lua:1060: in function 'changeScene'
    ...arooqi/Desktop/Crazy Candy 5 Jan 2013 5/wifigame.lua:276: in function 'a'
    ...arooqi/Desktop/Crazy Candy 5 Jan 2013 5/wifigame.lua:278: in function <...arooqi/Desktop/Crazy Candy 5 Jan 2013 5/wifigame.lua:269>
    ?: in function 'dispatchEvent'
    .../Farooqi/Desktop/Crazy Candy 5 Jan 2013 5/Client.lua:373: in function '_listener'
    ?: in function <?:534>
    ?: in function <?:229>

1 个答案:

答案 0 :(得分:0)

试试这个:

timer.performWithDelay(1000,function () direcor:changeScene( "PlayerClient" ) end)

而不是:

function a()
   direcor:changeScene( "PlayerClient" )
end

timer.performWithDelay(1000,a(),1)