代码如下:
var winSize=cc.winSize;
var rect1=new cc.DrawNode();
rect1.drawRect(cc.p(0,0),cc.p(200,250),cc.color(100,30,30,0),1,cc.Color(255, 0, 0, 0));
rect1.setAnchorPoint(1,1);
rect1.setPosition(winSize.width/2,winSize.height/2);
rect1.ignoreAnchorPointForPosition(false);
var ignore=rect1.isIgnoreAnchorPointForPosition();
cc.log("isIgnoreAnchorPointForPosition:"+ignore);
cc.log("getAnchorPoint:"+rect1.getAnchorPoint().x+","+rect1.getAnchorPoint().y);
this.addChild(rect1);
cc.log("rect1:"+rect1.x+","+rect1.y);
运行后的样子是:
我已经设置锚点是1,1,并且设置了不忽略锚点,为啥显示出来的图形定位还是以左下角为主的?找不到原因,求大神解答
控制台输出结果为:
JS: isIgnoreAnchorPointForPosition:false
JS: getAnchorPoint:1,1
JS: rect1:400,225JS: isIgnoreAnchorPointForPosition:false
JS: getAnchorPoint:1,1
JS: rect1:400,225
