Hi,
I am not sure if this is a bug or if I'm doing something completely wrong here. I quickly wrote a small test to illustrate it, just paste it in the AtlasTest.m in the cocos2d project to test it out.
The problem is that the elastic action is not running after being run for the first time. I've tried a number of different ways in order to get it to work. If I don't preload the CCBitmapFontAtlases then it runs just fine, but not on an iphone 2g! :' - ( I've read that there's not supposed to be any overhead creating a CCBitmapFontAtlas, but it seems to drag performance down on the iphone 2g, which it doesn't if I preload them.
I'm running v0.99.1.
Please help me! :)
@interface AtlasActionTest : AtlasDemo
{
NSMutableArray *a;
NSMutableArray *b;
}
-(void) removeLabel:(id)sender;
@end
@implementation AtlasActionTest
-(id) init
{
if( (self=[super init]) ) {
a = [[NSMutableArray alloc] init];
b = [[NSMutableArray alloc] init];
CGSize s = [[CCDirector sharedDirector] winSize];
for (uint i = 0; i < 5; i++) {
CCBitmapFontAtlas *label = [CCBitmapFontAtlas bitmapFontAtlasWithString:[NSString stringWithFormat:@"%d", i]
fntFile:@"bitmapFontTest.fnt"];
[label setPosition: ccp(s.width/2, s.height/2)];
[label setAnchorPoint: ccp(0.5f, 0.5f)];
[label setScale:0.f];
[a addObject:label];
id scale = [CCScaleTo actionWithDuration:0.8f scale:1.f];
id elastic = [CCEaseElasticInOut actionWithAction:scale];
id fadeOut = [CCSpawn actionOne:[CCFadeOut actionWithDuration:0.8f]
two:[CCMoveBy actionWithDuration:0.8f position:ccp(0.f,15.f)]];
id action = [CCSequence actions:elastic,
fadeOut,
[CCCallFuncN actionWithTarget:self selector:@selector(removeLabel:)], nil];
[b addObject:action];
}
[self schedule:@selector(step:) interval:1.f];
}
return self;
}
-(void) removeLabel:(id)sender {
[self removeChild:(CCNode *)sender cleanup:NO];
}
-(void) step:(ccTime) dt
{
CGSize s = [[CCDirector sharedDirector] winSize];
for (CCBitmapFontAtlas *label in a) {
if (![[self children] containsObject:label]) {
[self addChild:label];
[label runAction:[b objectAtIndex:[a indexOfObject:label]]];
break;
}
}
}
-(NSString*) title
{
return @"AtlasActionTest";
}
-(NSString *) subtitle
{
return @"Testing actions!";
}
-(void) dealloc {
[a release];
[b release];
[super dealloc];
}
@end