导演错误:场景名必须是字符串。场景 = nil。CORONA SDK。

我正在尝试使用导演类在 Corona 中创建我的第一个应用程序,但在我的初始代码中遇到了问题,以下是我的代码:

_W = display.contentWidth
_H = display.contentHeight

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

local main = function ()

    mainGroup:insert(director.directorView)
    director.changeScene("splashscreen")

    return true
end

main()

这是我的闪屏代码:

module(..., package.seall)

function new()
    local localGroup = display.newGroup ();

    local bgImage = display.newImageRect ( "splash_screen_images.png", _W, _H );
    bgImage:setReferencePoint(display.CentreRefrencePoint);
    bgImage.x = _W/2;
    bgImage.y = _H/2;

    localGroup:insert(bgImage);

    local delayTimer = timer.performWithDelay ( 3000, changeScreen, 1 )

    local function changeScreen1
            director:changeScene("meuscreen");
            timer.cancel ( delayTimer );
    end

    return localGroup
end

我无法运行此代码,始终出现如下错误:

Director 错误:场景名称必须是字符串。scene = nil

点赞
用户1979583
用户1979583

在你的 main.lua 页面中,将以下代码替换为:

director.changeScene("splashscreen")

替换为:

director:changeScene("splashscreen")

请注意,点号(.)被更改为冒号(:)。

2014-03-31 09:23:03