[Solved] Sprite setPosition error

[Solved] Sprite setPosition error
0.0 0


I am positioning an image sprite at location (0,0) so that left edge of screen co incides with left edge of image. But the image always appears at the center of the screen, with both the image and screen’s center coinciding.

The size of the CCImage is 854 x 480 and getVisibleSize() returns 320 x 240. To display the sprite with the image’s left coinciding with the screen’s left edge I have to setPosition at x= –264

I have gone through this wiki at cocos2dx wiki co-ordinates systems which says that (0,0) starts at left bottom. I have also seen Cocos2d-x reference of setPosition method which iterates the same.

Am I missing something? Any ideas why this may be happening?

UPDATE I think I should mention that I am using the CCLayerPanZoom extension for this. getAnchorPoint() returns x = 0.5 and y = 0.5


Anyone experienced this problem yet?


Try *setAnchorPoint( CCPointZero ). By default, sprites’ anchor points are registered in the center of the image.
sprite = CCSprite::create( “some_texture.png” );
sprite > setAnchorPoint;
> setPosition( CCPointZero );
this -> addChild( sprite);


Thanks. This resolved the issue.