I am building simple game with Sprite Kit in which level is built from identical rectangular blocks. But when I add to many block (i.e. 1000), game becomes very slow (FPS drops to 20). Here's how I add blocks to scene:
-(void)drawLevel
{
SKSpriteNode *shelf = [SKSpriteNode spriteNodeWithTexture:_initialLevel.earthBoxTexture];
shelf.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:shelf.size];
shelf.physicsBody.dynamic=NO;
shelf.physicsBody.categoryBitMask = platformCategory;
for (NSValue *positionValue in _initialLevel.boxPositions)
{
shelf.position = positionValue.CGPointValue;
[_platformsNode addChild:[shelf copy]];
}
[_world addChild:_platformsNode];
}
_world is a child of main scene. I create "shelf" once and than copy it. How should I do that to obtain good FPS?
App was tested on the iPhone 5.