Game Development Reference
In-Depth Information
usingBlock: ^(SKNode
*node, BOOL *stop)
{
SKSpriteNode * spaceBGNode = (SKSpriteNode
*) node;
CGPoint bgVelocity =
CGPointMake(-SPACE_BG_VELOCITY, 0);
CGPoint amtToMove =
CGPointMultiplyScalar(bgVelocity,self.diffTime);
spaceBGNode.position =
CGPointAdd(spaceBGNode.position, amtToMove);
//Checks if Background node is completely
scrolled of the screen, if yes then put it at the end
of the other node
if (spaceBGNode.position.x <=
-spaceBGNode.size.width)
{
spaceBGNode.position =
CGPointMake(spaceBGNode.position.x +
spaceBGNode.size.width*2,
spaceBGNode.position.y);
}
}];
}
5. Lastly, call this method every time in the update method of the game scene. After
that, you should see the spaceship flying in the sky with some nice white clouds.