title: Sprite Kit, force stop on physics
body: <p>I'm creating an <em>ongoing learning project</em> (basically I code while learning to use the framework in hope it will be useful for me and for someone else) for Sprite Kit (you can find it <a href="https://github.com/napolux/fallingpieces" rel="nofollow">here</a> if you are interested) but I'm facing some performance problems with my code.</p>
  
  <p>The project puts cubes on the screen and make them falling. <a href="https://github.com/napolux/fallingpieces/blob/master/fallingpieces/FLPPiece.m" rel="nofollow">Here's the class that creates the piece</a> </p>
  
  <pre><code>// The phisics for our falling piece:
  // It will be a square, subject to gravity of 5: check common.h (9.8 is way too much for us)
  self.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(self.size.width, self.size.height)];
  self.physicsBody.dynamic = YES;
  self.physicsBody.mass = 100;
  self.physicsBody.collisionBitMask = piecesCollisionBitmask;
  self.physicsBody.allowsRotation = NO;
  </code></pre>
  
  <p>and <a href="https://github.com/napolux/fallingpieces/blob/master/fallingpieces/FLPMyScene.m" rel="nofollow">here is the scene file with the loop</a>.</p>
  
  <pre><code>//schedule pieces
  SKAction *wait = [SKAction waitForDuration:1];
  SKAction *pieceIsFalling = [SKAction runBlock:^{
      FLPPiece *piece = [[FLPPiece alloc] init];
      [self addChild:piece];
  }];
  
  SKAction *fallingPieces = [SKAction sequence:@[wait,pieceIsFalling]];
  [self runAction:[SKAction repeatActionForever:fallingPieces]];
  </code></pre>
  
  <p>I suspect that physics is behind my frame rate drop. I would like to stop physics execution on node while keeping it on the screen as soon as it collides with something else.</p>
  
  <p>Is that possible? How can I do that?</p>