Cocos2d iphone 将LayerColor添加到节点时,此.\u parent.reorderChild不是函数
下面是cocos2djavascript函数Cocos2d iphone 将LayerColor添加到节点时,此.\u parent.reorderChild不是函数,cocos2d-iphone,cocos2d-x,cocos2d-js,Cocos2d Iphone,Cocos2d X,Cocos2d Js,下面是cocos2djavascript函数 spawnGrid: function(x,y) { var newGrid = cc.instantiate(this.gridPrefab).getComponent('Grid'); this.gameArea.addChild(newGrid.node); newGrid.init(x,y,10); var width = 75; var height = 75; var background
spawnGrid: function(x,y) {
var newGrid = cc.instantiate(this.gridPrefab).getComponent('Grid');
this.gameArea.addChild(newGrid.node);
newGrid.init(x,y,10);
var width = 75;
var height = 75;
var backgroundLayer = new cc.LayerColor(cc.Color.RED,width,height);
this.gameArea.addChild(backgroundLayer);
backgroundLayer.setPosition(cc.p(width * 0.5, height * 0.5));
}
当这行执行时
this.gameArea.addChild(backgroundLayer);
控制台显示此错误
Uncaught TypeError: this._parent.reorderChild is not a function
有什么想法吗?这可能太晚了,但供将来参考 我在试图在一个空节点(960x460)上画一条简单的线时遇到了相同的错误。在30分钟的沮丧之后,我发现有一个内部节点显然起了作用。这可能不是最好的解决方案,因为它是一个内部对象,可能会改变 因此,在您的情况下,临时解决方法是使用
this.gameArea._sgNode.addChild(backgroundLayer)
我希望这会有所帮助这可能会很晚,但供将来参考 我在试图在一个空节点(960x460)上画一条简单的线时遇到了相同的错误。在30分钟的沮丧之后,我发现有一个内部节点显然起了作用。这可能不是最好的解决方案,因为它是一个内部对象,可能会改变 因此,在您的情况下,临时解决方法是使用
this.gameArea._sgNode.addChild(backgroundLayer)
我希望这会有所帮助您能给我们展示一下游戏区初始化吗?只需编辑初始后扫描,您还可以向我们显示游戏区初始化吗?只需编辑初始帖子