Hi,
Thanks. I am just trying to understand why in all the samples, the sprites are positioned within the manager, but there is never a positioning of the manager itself..
#pragma mark Example Atlas 1
@implementation Atlas1
-(id) init
{
if( (self=[super init]) ) {
self.isTouchEnabled = YES;
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
[self addChild:mgr z:0 tag:kTagSpriteManager];
CGSize s = [[Director sharedDirector] winSize];
[self addNewSpriteWithCoords:ccp(s.width/2, s.height/2)];
}
return self;
}
-(void) addNewSpriteWithCoords:(CGPoint)p
{
AtlasSpriteManager *mgr = (AtlasSpriteManager*) [self getChildByTag:kTagSpriteManager];
int idx = CCRANDOM_0_1() * 1400 / 100;
int x = (idx%5) * 85;
int y = (idx/5) * 121;
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
[mgr addChild:sprite];
sprite.position = ccp( p.x, p.y);
id action;
float rand = CCRANDOM_0_1();
if( rand < 0.20 )
action = [ScaleBy actionWithDuration:3 scale:2];
else if(rand < 0.40)
action = [RotateBy actionWithDuration:3 angle:360];
else if( rand < 0.60)
action = [Blink actionWithDuration:1 blinks:3];
else if( rand < 0.8 )
action = [TintBy actionWithDuration:2 red:0 green:-255 blue:-255];
else
action = [FadeOut actionWithDuration:2];
id action_back = [action reverse];
id seq = [Sequence actions:action, action_back, nil];
[sprite runAction: [RepeatForever actionWithAction:seq]];
}
Notice the positionng of AtlasSprites, but the AtlasSpriteManager is only added with a index, and the position is never set. This is why thought the sprites are actually being positioned in the Managers "parent" rather than the manager itself.
hope the question makes sense!
i