1

I'm throwing a lot of objects across the screen (1 beachball every 0.1s) and swiping them toward a box, the balls are recycled after they leave the screen or hit the ball. The problem i encountered is that when multiple balls hit the box, frame rates drop drastically. I'm not sure what's making this happen. Is there a better way to do the following so that it doesn't lag? I use the default cocos library to play sounds.

-(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair can:(CCNode *)nodeA wildcard:(CCNode *)nodeB {
    if([nodeB.physicsBody.collisionType isEqualToString:@"hit"]){
        [[_physicsNode space] addPostStepBlock:^{
            [self remove:nodeA];
        } key:nodeB];
    }else if([nodeB.physicsBody.collisionType isEqualToString:@"floor"]){
        [[_physicsNode space] addPostStepBlock:^{
            [self remove:nodeA];
        } key:nodeB];
    }else {
        [self playSound:@"collide.mp3" bg:YES];
    }
}
  • how many beach balls ? on a device ? are the sprites all from a single texture ? if yes, are all the sprite added as children to the same node ? What is dramatic drop (on a device) ? – YvesLeBorg Apr 03 '15 at 11:28
  • 1 every 0.1 seconds. It's a continuous stream. It doesn't lag until a ball touches the box. Yes device testing. Yes all the same texture. It's just 1 image on 1 node. The drop goes from 60fps to around 2 or 0 for a while. Then when the ball stops touching the box, back to normal @YvesLeBorg –  Apr 03 '15 at 23:16

0 Answers0