I have a CClayer class and when this class inits it creates a CCSprite that should be centered, so later, when I rotate an object created with that CCLayer class, it rotates around its center. I mean, if the sprite on that class is an image 200 pixels wide and 300 pixels height, I want the CCLayer pivot to be at 100,150.
I have tried to set it at 0,0 and 0.5,0.5 without success.
As far as I understand, CCLayer has no bounding box, it is like a kind of node, right? so, I create the class like this:
-(id) initWithImage:(UIImage*)image Name:(NSString*)name
{
if( (self=[super init])) {
self.isTouchEnabled = YES;
self.mySprite =
[CCSprite spriteWithCGImage:image.CGImage key:name];
self.mySprite.position = CGPointZero;
[self addChild:self.mySprite];
self.mySprite.anchorPoint = ccp(0.0f, 0.0f);
// have tried also 0.5f, 0.5f... no success
}
return self;
}
How do I do that?
thanks