0%

Book Description

Develop games for iOS and Android using Cocos2d with the aid of over 70 step-by-step recipes

About This Book

  • Learn to efficiently use Cocos2d to develop cross-platform games, and have them work on iOS as well as Android
  • Get acquainted with industry-wide professional tools such as Glyph Designer, Texture Packer, and Physics Editor, as well as using the Swift/ Sprite builder implementation of Cocos2d
  • Use the easy-to-follow recipes to develop as well as deploy games to the Playstore and the App Store

Who This Book Is For

This book is for intermediate game developers and especially the ones who are generally curious to find out what’s new in Cocos2d v 3.3.

What You Will Learn

  • Build custom sprites with custom animations for the game
  • Build interactivity into your game by adding gestures and touch interactions
  • Understand AI enemy programming and path finding to make games more exciting
  • Add physics to your game to make it more lively and interactive
  • Get familiar with the Swift and Sprite builder implementations along with Objective-C programming
  • Perform hassle-free deployment of games built in iOS onto Android
  • Add effects and particle systems to make the game more colorful

In Detail

Cocos2d is the world’s leading game development framework for developing iOS games. With the introduction of Swift and Spritebuilder, it has become easier than ever to develop the games of your dreams without much effort. With Cocos2d, you can also deploy the game on Android, thereby maximizing profit and reducing development and porting costs.

The book starts off with a detailed look at how to implement sprites and animations into your game to make it livelier. You will then learn to add scenes to the game such as the gameplay scene and options scene and create menus and buttons in these scenes, as well as creating transitions between them. From there on, you will get an understanding of how to program user interactions such as tapping, holding, and swiping. You’ll then add accelerometer inputs and physics to the scene, and make objects respond back to the inputs. A game is practically incomplete without audio being added, so this will be covered next.

The next section will include ways to add Artificial Intelligence to enemies in the game, allowing them to patrol, chase, and shoot in a projectile manner. You will then learn to use NSUserDefault to save and load game progress, and create and access files using JSON, Plist, and XML files for custom storage and retrieval of data. Then you will learn to add dynamic lighting to your game and will use industry-wide tools such as Texture Packer, Glyph Designer, Physics Editor, Particle Designer, and Sprite Illuminator to create more visually appealing and performance-optimized games.

Towards the end of the book, we dive into Apple’s latest programming language—Swift, highlighting the major differences between Objective C and Swift. The book culminates with taking your existing game developed for iOS and porting it to Android, showing you how to install the Android Xcode plugin as well.

Style and approach

The book is written in an extremely lucid and step-by-step manner; it can be understood easily by anyone. The topics included are broken down into individual chapters so you can refer to the specific chapter to get answers on the subject you are interested in.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Cocos2d Cross-Platform Game Development Cookbook Second Edition
    1. Table of Contents
    2. Cocos2d Cross-Platform Game Development Cookbook Second Edition
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
    7. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why Subscribe?
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    9. 1. Sprites and Animations
      1. Introduction
      2. Downloading and installing Cocos2d
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. The 2D coordinate system
      4. Getting access to MainScene
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Adding sprites to scenes
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Creating a sprite using RenderTexture
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      7. Creating a custom sprite class
        1. Getting ready
        2. How to do it…
        3. How it works…
      8. Animating sprites
        1. Getting ready
        2. How to do it…
        3. How it works…
      9. Adding actions to sprites
        1. Getting started
        2. How to do it…
        3. How it works…
        4. There's more…
      10. Drawing glPrimitives
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      11. Adding the parallax effect
        1. Getting ready
        2. How to do it…
        3. How it works…
    10. 2. Scenes and Menus
      1. Introduction
      2. Adding a MainMenu Scene
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Adding text using CCLabel
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      4. Adding buttons with CCMenu
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Adding a Gameplay Scene
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Transitioning between scenes
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      7. Adding transition effects
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      8. Adding a Level Selection Scene
        1. Getting ready
        2. How to do it…
        3. How it works…
      9. Scrolling a Level Selection Scene
        1. Getting ready
        2. How to do it…
        3. How it works…
    11. 3. Gestures, Touches, and the Accelerometer
      1. Introduction
      2. Understanding swipe
        1. Getting started
        2. How to do it…
        3. How it works…
        4. There's more…
      3. Implementing tap
        1. Getting started
        2. How to do it…
        3. How it works…
      4. Adding LongPress
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Adding pinch/zoom controls
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Adding rotation objects
        1. Getting ready
        2. How to do it…
        3. How it works…
      7. Adding panning
        1. Getting ready
        2. How to do it…
        3. How it works…
      8. Including touches
        1. Getting ready
        2. How to do it…
        3. How it works…
      9. Creating objects with touchBegan
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      10. Moving objects with touchMoved
        1. Getting ready
        2. How to do it…
        3. How it works…
      11. Customizing touches in the sprite class
        1. Getting ready
        2. How to do it…
        3. How it works…
      12. Adding an accelerometer
        1. Getting ready
        2. How to do it…
        3. How it works…
      13. Adding a directional pad
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
    12. 4. Physics
      1. Introduction
      2. Adding physics to a game scene
        1. Getting started
        2. How to do it…
      3. Adding physics objects
        1. Getting started
        2. How to do it…
        3. How it works…
      4. Looking at different body types
        1. Getting started
        2. How to do it…
        3. How it works…
      5. Adding sprite texture to physics objects
        1. Getting started
        2. How to do it…
        3. How it works…
      6. Creating composite bodies
        1. Getting started
        2. How to do it…
        3. How it works…
      7. Creating complex shapes
        1. Getting started
        2. How to do it…
        3. How it works…
      8. Changing body properties
        1. Getting started
        2. How to do it…
        3. How it works…
        4. There's more…
      9. Applying impulse with the touch control
        1. Getting started
        2. How to do it…
        3. How it works…
      10. Applying force with the accelerometer
        1. Getting started
        2. How to do it…
        3. How it works…
      11. Collision detection
        1. Getting started
        2. How to do it…
        3. How it works…
      12. Adding revolute joints
        1. Getting started
        2. How to do it…
        3. How it works…
      13. Adding motor joints
        1. Getting started
        2. How to do it…
        3. How it works…
      14. Adding a game loop and scoring
        1. Getting ready
        2. How to do it…
        3. How it works…
    13. 5. Audio
      1. Introduction
      2. Adding background music
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Adding audio effects
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Adding a mute button
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Adding a volume slider
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Adding a pause and resume button
        1. Getting started
        2. How to do it…
        3. How it works…
    14. 6. AI and A* Pathfinding
      1. Introduction
      2. Patrol enemy behavior
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Projectile shooting enemy
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Chasing enemy behavior
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. A* pathfinding
        1. Getting ready
        2. How to do it…
        3. How it works…
    15. 7. Data Storage and Retrieval
      1. Introduction
      2. Loading the XML file data
        1. Getting started
        2. How to do it…
        3. How it works…
      3. Saving to the XML file data
        1. How to do it…
        2. How it works…
      4. Loading the JSON file data
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Loading the PLIST file data
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Saving the PLIST file data
        1. Getting ready
        2. How to do it…
        3. How it works…
      7. Using NSUserDefaults
        1. How to do it…
        2. How it works…
    16. 8. Effects
      1. Introduction
      2. CCEffects
        1. Getting ready
        2. How to do it…
          1. Adding the bloom effect
          2. Adding the blur effect
          3. Adding the brightness effect
          4. Adding the drop shadow effect
          5. Adding the pixelate effect
          6. Adding the stack effect
        3. How it works…
      3. Adding the glass effect
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Adding the motion streak effect
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Adding the particle effect
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      6. Adding 2D lighting
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
    17. 9. Game Tools
      1. Introduction
      2. Glyph Designer
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Particle system
        1. Getting ready
          1. Particle Designer
          2. Emitter configuration
          3. Particle Settings
          4. Color settings
          5. Texture settings
          6. Particle2dx
          7. Motion
          8. Color&Shape
          9. Template
          10. Export
        2. How to do it…
        3. How it works…
      4. TexturePacker
        1. Getting ready
          1. Data
          2. Texture
          3. Layout
          4. Sprites
        2. How it works…
      5. PhysicsEditor
        1. Getting ready
        2. How to do it…
        3. How it works…
    18. 10. Swift/SpriteBuilder Basics
      1. Introduction
      2. Implementing the Swift syntax
        1. Getting started
        2. How to do it…
          1. Variables
          2. Operators
            1. Arithmetic operators
          3. Comparison operators
          4. Logical operators
          5. Arithmetic increment/decrement and assignment operations
          6. Control flow statements
            1. Decision making statements
              1. The if statement
              2. The if else statement
              3. The else if statement
              4. The conditional expression
              5. The switch statement
            2. Looping statements
              1. The while loop
              2. Repeating the while loop
              3. The for loop
              4. The for in loop
          7. Arrays
            1. Looping through arrays
            2. Adding, removing, and inserting objects in arrays
            3. Important array functions
          8. Dictionary
            1. Adding and removing objects in a dictionary
            2. Looping through items in a dictionary
            3. Dictionary functions
          9. Functions
            1. Simple functions
            2. Passing a parameter
            3. Passing more than one parameter
            4. Returning a value
            5. Default and named parameters
            6. Returning more than one value
          10. Classes
            1. Properties and initializers
            2. Custom methods
          11. Inheritance
          12. Access specifiers
          13. Optionals
      3. Implementing Cocos2d Swift
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. SpriteBuilder basics
        1. Getting ready
        2. How to do it…
        3. How it works…
    19. 11. Porting to Android
      1. Introduction
      2. Installing the Android Xcode plugin
        1. Getting started
        2. How to do it…
      3. Enabling USB debugging on a device
        1. How to do it…
      4. Running the SpriteBuilder project on a device
        1. How to do it…
      5. Porting a project to Android
        1. How to do it…
      6. No Java runtime error
        1. How to do it…
      7. Provision profile error
        1. How to do it…
      8. Blank screen error
        1. How to do it…
      9. Useful resources
    20. Index
18.222.114.28