– main.lua
require(“app.Update”).new():run();
– Update.lua
require(“config”)
require(“framework.init”)
local Update = class(“Update”, cc.mvc.AppBase);
function Update:ctor()
cc.FileUtils:getInstance():addSearchPath(“res/”); – 添加搜索路径
Update.super.ctor(self);
end
function Update:run()
self:enterScene(“UpdateScene”, nil, “fade”, 0.6, display.COLOR_WHITE);
end
function Update:enterLogin()
self:enterScene(“Login”, nil, “fade”, 0.6, display.COLOR_WHITE);
end
– UpdateScene.lua
require(“framework.init”);
local NetWork = require(“framework.netWork”);
local moduleCfg = require(“moduleCfg”); – 配置文件
local UpdateScene = class(“UpdateScene”, function()
return display.newScene(“UpdateScene”)
end)
function UpdateScene:ctor()
cc.FileUtils:getInstance():addSearchPath(“res/”); – 添加搜索路径
app:enterLogin(); ---- 问题就出在这里了,它不会进入到Login场景,也没报错之类的。但是我在这里使用button的点击事件调用这句的话是正常进入Login场景的,请看下面代码。
end
–
– 这里是正常的代码
function UpdateScene:ctor()
cc.FileUtils:getInstance():addSearchPath(“res/”); – 添加搜索路径
self.m_bg:setTouchEnabled(true);
self.m_bg:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == “began” then
print("======== button enterLogin");
app:enterLogin(); ---- 这里就能正常相应按钮事件进入Login场景。
return true;
end
end);
end
–]]
–
还有一种情况
function UpdateScene:onEnter()
app:enterLogin(); – 我将这句移到这里,会进入到Login场景,但是又闪回UpdateSecen场景了。log还输出了“cocos2d: removeChildByTag(tag = -86050082): child not found!”
end
–]]
以上这两种情况不知道怎么回事,怎么很好地解决,请指点。
我不想通过按钮按下的事件来触发进入Login场景。换句话说,我想在场景UpdateScene里面做一些初始化,数据处理(异步处理,例如下载东西)后,到达一定条件才进入到Login场景,请问能怎么做?查了两天还暂时找不到方法,所以发帖来求救了。
谢谢!

