Cocos2d JS HTML5 -
i want rotate image in cocos2d java-script html5. upper , lower circles 2 different sprites. using code:
var rotationamount=0; top=cc.sprite.create("assets/top.png"); top.setposition(midx,midy+100); top.schedule(function(){ if(rotationamount>360) rotationamount=0; }); this.addchild(top);
here's how sprites look:
the above causes sprite starts rotate around itself. want make rotate around point, going wrong?
you can next:
var top = cc.sprite.create("assets/top.png"); var rotateaction = cc.rotateby.create(0, 1); top.attr({ x: midx, y: midy, anchorx: 0.5, anchory: 0.5 }); top.schedule(function() { top.runaction(rotateaction); }); this.addchild(top);
Comments
Post a Comment