0%

Book Description

Master game development with Cocos2d to develop amazing mobile games for iOS

In Detail

Cocos2d is one of the world's leading 2D game development engines, letting game developers create awesome games with ease. Its multiplatform capabilities meet the demands of modern game development. If you want to dive into Cocos2d game development and create exciting, high quality games, this book is an advanced and reliable resource. Covering the most important game development tools, and guiding you through the development cycle of a complete 2D game, Mastering Cocos2d Game Development will build your confidence and inspire you to go further in game development.

Combining practical steps with detailed insights, this book will help you discover and learn a powerful approach to game development to create exceptional iOS games, tips to create cool content, and how to harness the unique power of Swift.

What You Will Learn

  • Prototype a game quickly and easily
  • Use the physics engine to apply forces and detect collisions
  • Engage your user with the best sound effects a game can have
  • Create interesting, engaging mechanics
  • Polish your game and make it worth playing
  • Explore the full functionality of Cocos2d through easy-to-follow examples and practical guidance designed to help you complete your own game development projects
  • Make use of Apple's new Swift language
  • Develop a high quality game for iOS
  • Understand the Cocos2d-Swift architecture and its main classes

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 files e-mailed directly to you.

Table of Contents

  1. Mastering Cocos2d Game Development
    1. Table of Contents
    2. Mastering Cocos2d Game Development
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Refreshing Your Cocos2d Knowledge
      1. Preparing the mindset
        1. The physics engine
        2. In-App Purchases
        3. Making use of analytics
        4. Complex mechanics and special effects
      2. Choosing tools and getting started
        1. TexturePacker
        2. Particle Designer
        3. Glyph Designer
        4. VertexHelper
        5. GAF
        6. Git and GitHub/Bitbucket
      3. Setting flexible, focused goals
        1. Expand
        2. Focus
        3. Flex
      4. Downloading the IDE and Source Code
        1. Step 1 – become a developer through Apple's iOS program
        2. Step 2 – download and install Xcode
          1. Adding a device
        3. Step 3 – download Cocos2d (via SpriteBuilder)
        4. Creating a new project via SpriteBuilder
        5. Exporting SpriteBuilder projects to Xcode
      5. Summary
    9. 2. Failing Faster with Prototypes
      1. File suffixes versus directories
      2. Why prototype?
        1. Playtesting and feedback analysis
        2. Project for the book
        3. A quick mock-up
        4. Overview of how the Cocos2d engine works
      3. Getting a scene up and running
        1. Creating the initial code for the scene to open
        2. Run it on the simulator – doesn't require an iOS developer license
        3. Run it on the device – requires an iOS developer license
      4. Creating buttons and text (labels)
        1. Let's get some text displayed – CCLabelTTF
        2. Let's get some text displayed – CCLabelBMFont
          1. Saving your BMFont using file suffixes
          2. Saving your BMFont using directories
          3. Exporting the BMFont and importing to Xcode
        3. Not using TexturePacker – A brief how-to
      5. Begin using sprite sheets with TexturePacker
        1. Saving to the project location
        2. Scaling the images and publishing the sprite sheet
        3. Importing the sprite sheet and loading it into the memory
      6. Creating buttons via CCButton and CCLayout
        1. Adding the Restart button
      7. Creating nodes and units (sprites)
        1. Setting up the background
        2. Defining and adding a unit to the screen
        3. Moving the units around with touch controls
        4. Talking between scenes
        5. Interaction with enemies and scoring
      8. Creating menus, scenes, and scene transitions
        1. Creating a new file for the scene
        2. Turning a class into an official CCScene subclass
        3. Linking the button in the game to go to the menu
        4. Creating and linking a button in the menu to go to the game
      9. Where to go from here?
        1. Some suggestions
      10. Summary
    10. 3. Focusing on Physics
      1. Learn how Chipmunk works
        1. Overall structure of Chipmunk
        2. Types of bodies
      2. Setting up a project and creating basic objects
        1. Setting up Cocos2d for use with physics
        2. Building a world for physics to exist
        3. Enabling touch creation of our object
        4. Making the objects fall – adding CCPhysicsBody
        5. Adding the ground and walls
      3. Setting gravity by tilting the device
        1. Setting up the accelerometer
        2. Reading the data
        3. Manipulating gravity to your heart's content
      4. Handling collisions in Chipmunk
        1. Setting the collision delegate
        2. Setting collision tags on game objects
        3. Detecting collision
      5. Using Chipmunk for just collision detection
        1. Turning the physics body into a sensor
      6. Summary
    11. 4. Sound and Music
      1. Prerequisites
      2. Seeing the difference in audio types
      3. Learning about OALSimpleAudio
        1. Preloading effects
        2. Loading files asynchronously
        3. Unloading effects
      4. Playing sound effects and loop background music
        1. Getting some background music going
        2. Sounds when a button is clicked on
        3. Sounds on unit movements
        4. Sounds on unit combination
        5. Sounds when the user loses
      5. Modifying the sound effect on the fly
        1. The volume (or gain), pitch, and pan
        2. Stopping looped sound effects
        3. Modifying the combine sound effect
      6. Other great sound places
      7. Summary
    12. 5. Creating Cool Content
      1. Adding a table for scores
        1. CCTableView versus UITableView
        2. Saving high scores (NSUserDefaults)
        3. Creating the table
        4. Showing the scores
      2. Adding subtle sliding to the units
        1. Sliding one unit
        2. Sliding all units
      3. Creating movements on a Bézier curve
        1. Examples of using a Bézier curve
        2. Sample project – Bézier map route
        3. Curved M-shape
      4. Depth perception via device tilting
        1. Isn't this parallax scrolling?
        2. Sample project – depth
        3. Creating the parallax node and adding the objects
        4. Visualizing the depth
        5. Restoring equilibrium (calibrating to the new rotation)
        6. A quick scrolling example
      5. Three ways to make unit streamers or "ghosts"
        1. Sample project – ghosts
        2. Method 1 – particle systems
        3. Method 2 – sprites or nodes
        4. Method 3 – constant line
      6. Touchscreen controls versus D-pad adaptation (and why it matters so much to know this distinction)
        1. Bad examples of iOS game controls
        2. Great examples of touchscreen controls
      7. Summary
    13. 6. Tidying Up and Polishing
      1. Button press visuals
        1. Modifying the CCButton class
      2. Pulse on unit combine
      3. Tutorial
        1. Tutorial phase variable and the NSUserDefaults key
        2. Displaying text for each phase (and CCSprite9Slice)
        3. Advancing the tutorial
        4. Advancing in all the right places
        5. Removing the previous phases' text
        6. Fingers pointing the way
        7. Rejecting non-tutorial movement
      4. Sharing on Facebook and Twitter (and more)
        1. Using the built-in share feature
        2. Creating the Share button
        3. Creating a variable for the current score
        4. Creating the UIActivityView object
        5. Displaying UIActivityViewController
        6. Adding a screenshot to the share
      5. Turning sounds on and off
        1. No options or settings? Main menu it is!
        2. Creating the buttons
        3. Creating the keys
        4. Grabbing the sound and music Boolean from NSUserDefaults
        5. Setting and saving the values
        6. Pausing/resuming background music and sound
        7. Handling MainScene sound
        8. Repeating for GameOverScene (and any other scenes)
        9. Handling AppDelegate music
        10. Making sure that sound/music starts enabled
      6. Game Center leaderboards
        1. Creating the App ID
        2. Creating the app in iTunes Connect
        3. Creating the leaderboard
        4. Adding the GameKit framework
        5. GameKit helper files
        6. Authenticating the user
        7. Creating the Game Center button
        8. Submitting the score
      7. Slide transition
        1. Creating a generic slide function
        2. Extending the background
        3. Replacing the scene with a rubber band transition
        4. Transition in MenuScene
        5. Transition in GameOver
        6. Other ideas for polishing
      8. Summary
    14. 7. Reaching Our Destination
      1. Adding a default image
        1. Adding the loading screen
        2. Switching to LoadingScene from MainScene
      2. Icons
        1. Template
        2. Adding the icons to the project
        3. Asset catalog
      3. Analytics and user data
        1. Signing up for Flurry
        2. Adding Flurry to your project
        3. Logging events
        4. Tracking and visualizing the data
      4. Preparing the app on iTunes Connect
      5. Releasing the game and steps after it
        1. After submission
        2. Beta testers and the target market
        3. App review sites
        4. Other sources of information
      6. Summary
    15. 8. Exploring Swift
      1. How Swift works
      2. Learning Swift through Playgrounds
        1. How Playgrounds are organized
        2. Viewing the results over time
        3. Learning more about Swift
      3. Creating a game in Swift instead of Objective-C
        1. Goal of the game
        2. Starting a new Swift project
        3. Adding the font files
        4. Importing Bridging-Header and loading MainScene
        5. Creating the background, turret, and score label
        6. Rotating the turret with touchMoved
        7. Shooting some bullets
        8. Spawning enemies and sending them towards the center
        9. Transitioning to GameOver
        10. Handling collisions
        11. Counting the score
        12. Increasing the difficulty
      4. Summary
    16. Index
3.137.163.197