我想添加几个标签,每个之间有一个时间延迟顺序出现。标签将显示0或1,并且该值是随机计算的。我运行下面的代码:插入时间延迟与cocos2d
for (int i = 0; i < 6; i++) {
NSString *cowryString;
int prob = arc4random()%10;
if (prob > 4) {
count++;
cowryString = @"1";
}
else {
cowryString = @"0";
}
[self runAction:[CCSequence actions:[CCDelayTime actionWithDuration:0.2] ,[CCCallFuncND actionWithTarget:self selector:@selector(cowryAppearWithString:data:) data:cowryString], nil]];
}
,使标签显示的方法是这样的:
-(void)cowryAppearWithString:(id)sender data:(NSString *)string {
CCLabelTTF *clabel = [CCLabelTTF labelWithString:string fontName:@"arial" fontSize:70];
CGSize screenSize = [[CCDirector sharedDirector] winSize];
clabel.position = ccp(200.0+([cowries count]*50),screenSize.height/2);
id fadeIn = [CCFadeIn actionWithDuration:0.5];
[clabel runAction:fadeIn];
[cowries addObject:clabel];
[self addChild:clabel];
}
这段代码的问题是,所有的标签出现在同一时刻以相同的延迟。我明白,如果我使用[CCDelayTime actionWithDuration:0.2*i]
代码将工作。但问题是,我可能还需要迭代整个循环,并在第一次出现标签后再次出现标签。怎么可能有行动出现延迟和行动不总是遵循相同的顺序或迭代?
什么框架是在导入这个? – luca590 2011-05-24 21:10:28