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

1 回答 1

0

尝试这个 :

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

代替:

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

timer.performWithDelay(1000,a(),1)
于 2013-01-10T10:04:33.207 回答