Anchor Points in cocos2d
As we are familiar by now, cocos2d organizes everything in nodes. Each node has an anchor point and by default, the anchorPoint property is 0.5, 0.5 which is half the size of the texture and 0.5, 0.5 is measured in terms of % (i.e. a factor of the texture size).
anchorPoint and node position are completely different concepts. When we change the anchorPoint and we see a sprite change its position on screen, the node’s position does not actually change. We are merely moving the sprite’s texture around.
In short, the anchorPoint is an offset of the texture relative to the node’s position. Setting our anchorPoint to 0,0 effectively places the texture’s lower left corner at the node’s position. Therefore, in this example, the sprite image will neatly align with the lower left corner of the screen:
CCSprite* sprite = [CCSprite spriteWithFile:@"Default.png"]; sprite.anchorPoint = CGPointMake(0,0); [self addChild:sprite];
This is a simple example but for all practical purposes, we usually want our anchorPoint at the center of the texture and we usually do not want to specify the anchorPoint to 0,0.