@405353624 写道:
var clipper = new cc.ClippingNode(); clipper.tag = TAG_CLIPPERNODE; clipper.width = 200; clipper.height = 200; clipper.anchorX = 0.5; clipper.anchorY = 0.5; clipper.x = this.width / 2; clipper.y = this.height / 2; clipper.runAction(cc.rotateBy(1, 45).repeatForever());
//A===============================================
var stencil = new cc.DrawNode();
var rectangle = [cc.p(0, 0),cc.p(clipper.width, 0),
cc.p(clipper.width, clipper.height),
cc.p(0, clipper.height)];var white = cc.color(255, 255, 255, 255); stencil.drawPoly(rectangle, white, 1, white); clipper.stencil = stencil;
//B================================================
this.addChild(clipper);如果把代码" this.addChild(clipper);"放到A处,运行报错
CCClippingNode.js:94 Uncaught TypeError: Cannot read property 'onEnter' of null,
但是如果放在B处就不会报错
帖子: 2
参与者: 1