Cocos 页面跳转随机动画崩溃

self:getApp():enterScene("PlayScene", "random") 最终call到display.wrapScene(scene, transition, time, more)

当transition传入random的时候,type(t)一直返回table,但是t[1],t[2]可能为nil,直接报错了
function display.wrapScene(scene, transition, time, more)
    local key = string.upper(tostring(transition))

    if key == "RANDOM" then
        local keys = table.keys(display.SCENE_TRANSITIONS)
        key = keys[math.random(1, #keys)]
    end

    if display.SCENE_TRANSITIONS[key] then
        local t = display.SCENE_TRANSITIONS[key]
        time = time or 0.2
        more = more or t[2]
        if type(t) == "table" and (t[1] ~= nil and t[2] ~= nil) then
            scene = t[1]:create(time, scene, more)
        else
            scene = t:create(time, scene)
        end
    else
        error(string.format("display.wrapScene() - invalid transition %s", tostring(transition)))
    end
    return scene
end 


你可能感兴趣的:(Cocos 页面跳转随机动画崩溃)