Time for action – moving and following the bird

What is the purpose of the big world if we can see only a small portion of it? Let's make the bird fly forward and see the whole tile map. Perform the following steps:

  1. Open the TilemapScene.m file and add the update: method to move the tile map as follows:
    -(void)update:(CCTime)dt
    {
        float distance = 150.0f * dt;
        
        CGPoint newTilemapPos = _tileMap.position;
        newTilemapPos.x = newTilemapPos.x - distance;
        _tileMap.position = newTilemapPos;
    }
  2. You can build and run the game right now, but you will see that the bird isn't stopping when we reach the end of the tile map. So let's change the update: method to the following code:
    -(void)update:(CCTime)dt { float distance = 150.0f * dt; CGPoint newTilemapPos = _tileMap.position; ...

Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.