设置一个全局变量temp,然后在 GameScene里面设置temp=this.
然后在UI.function里面这样么写 temp.runAction(cc.Sequence.create(cc.DelayTime.create(1),cc.CallFunc.create(function () {temp.addChild(sprite2)}))); 总算成功了…
但是,问题又来了,cc.Sequence.create应该支持数组的吧?
来个tempArr,设置tempArr=cc.DelayTime.create(1)
tempArr=cc.CallFunc.create(function () {temp.addChild(sprite2)})
其他都不变,放到 temp.runAction(cc.Sequence.create(tempArr))
然后又失败了。。。
迷茫啊迷茫。
var temp;
var UI= {
main : function () {
var sprite1 = cc.Sprite.create(“1-1.png”);
sprite1.x = cc.winSize.width/2 - 54;
sprite1.y = cc.winSize.height/2 + 54;
temp.addChild(sprite1);
var sprite2 = cc.Sprite.create(“1-2.png”);
sprite2.x = cc.winSize.width/2 + 54;
sprite2.y = cc.winSize.height/2 - 54;
//temp.addChild(sprite2);
var tempArr={};
tempArr=cc.DelayTime.create(1);
tempArr=cc.CallFunc.create(function () {temp.addChild(sprite2)});
temp.runAction(cc.Sequence.create(tempArr));
},
}
var GameScene = cc.Scene.extend({
temp = this;
});