Skip to Main Content
Learning iPhone Game Development with Cocos2D 3.0
book

Learning iPhone Game Development with Cocos2D 3.0

by Kirill Muzykov
June 2014
Beginner to intermediate content levelBeginner to intermediate
434 pages
9h 49m
English
Packt Publishing
Content preview from Learning iPhone Game Development with Cocos2D 3.0

Time for action – using parallax scrolling

The parallax scrolling technique adds depth to your game by moving different layers placed one above each other at different speed. Let's use it in our TilemapScene class and you'll see what I'm talking about. Perform the following steps:

  1. Open the TilemapScene.m file and add the following instance variable:
    @implementation TilemapScene
    {
        //..skipped..
    
        CCParallaxNode *_parallaxNode;
    }
  2. Then find the addTilemap method and replace it with the following code:
    -(void)addTilemap { _tileMap = [CCTiledMap tiledMapWithFile:@"tilemap.tmx"]; _worldSize = _tileMap.contentSizeInPoints.width; //1 CCTiledMapLayer *bushes = [_tileMap layerNamed:@"Bushes"]; CCTiledMapLayer *trees = [_tileMap layerNamed:@"Trees"]; CCTiledMapLayer ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

James Goodwill, Wesley Matlock

Publisher Resources

ISBN: 9781782160144Supplemental Content