I want to drop some objects after every 5 seconds. My problem is that, the animal which is first to come up on the screen falls but the animals after that do not fall they stuck to their original positions.
my code for dropping animal is:
-(void)dropAnimal
{
[self performSelector:@selector(dropAnimal) withObject:nil afterDelay:5];
prevojectIndex=objectIndex;
prevIndex=currentIndex;
float padding = sw*128/768;
float x = (float)(arc4random()%(int)(sw-padding*2))+padding;
if([SpritesARRAY count]>0)
{
objectIndex=arc4random()%[SpritesARRAY count];
object=[SpritesARRAY objectAtIndex:objectIndex];
object.falling = YES;
currentIndex=arc4random()%[animalsArray count];
[object initWithSpriteFrameName:[animalsArray objectAtIndex:currentIndex]];
object.position = ccp(x, sh*31/32-self.position.y);
objectsDictionary=[NSMutableDictionary dictionary];
[objectsDictionary setObject:object forKey:[[NSNumber numberWithInt:objectIndex] stringValue]];
[objectsDictionary retain];
[SpritesARRAY removeObjectAtIndex:objectIndex];
[self animateAnimal];
}
}
-(void) animateAnimal
{
FallAnimal *CurObject=[objectsDictionary objectForKey:[[NSNumber numberWithInt:objectIndex] stringValue]];
[CurObject runAction:[CCMoveTo actionWithDuration:2 position:CGPointMake(CurObject.position.x,90)]];
[CurObject release];
}