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:
- Open the
TilemapScene.m
file and add theupdate
: 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; }
- 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; newTilemapPos.x = newTilemapPos.x - distance; CGSize viewSize = [CCDirector sharedDirector].viewSize; float endX = -1 * _worldSize + viewSize.width; if...