The sprite has a content size of (42, 42), so the getAnchorPointInPoints must return (21, 21) ?
However, it always returns (0, 0) , and when I rotate the sprite, it will rotate around its (0, 0) position.
How can I solve this?
Do you preload this resource?
>
Because browser load resource is Asynchronous, so you need preload resource before create sprite.
>
In HelloHTML5World testcase, we define list of preload resources in src/resource.js。
Yes, I preloaded images before using them. Furthermore, logging the sprite.getContentSize() after defining sprite, gets the correct size of image.
Fixed!
For others that have a same problem:
move the following code to the last of “init” and “initWithTexture” functions in CCSprite.js file: // default transform anchor: center this.setAnchorPoint(cc.p(0.5, 0.5));