You are previewing Learn SpriteBuilder for iOS Game Development.
O'Reilly logo
Learn SpriteBuilder for iOS Game Development

Book Description

SpriteBuilder is the fun and versatile game development environment that is a natural successor to Cocos2D, Cocos3D, and Chipmunk2D. In Learn SpriteBuilder for iOS Game Development, experienced game developer and author Steffen Itterheim shows you how to get the most out of SpriteBuilder to create a full-featured 2D action game that you can use as a basis for your own games.

You'll learn SpriteBuilder best practices, how to incorporate SpriteBuilder into your game development workflow, and how to use the various features of SpriteBuilder, including game physics, scrolling, menus, and playing audio assets. You'll learn everything from the basics to advanced topics like visual effects, soft-body physics, rendering textured polygons and porting to Android. You'll be using both SpriteBuilder and the latest version of Cocos2D, version 3. If you have a bit of iOS development experience and you want to learn to create imaginative 2D games, Learn SpriteBuilder for iOS Game Development is exactly the book you need.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Contents at a Glance
  5. Contents
  6. Dedication
  7. About the Author
  8. About the Technical Reviewers
  9. Acknowledgments
  10. Introduction
  11. Part I: Introducing SpriteBuilder and cocos2D-iphone version 3
    1. Chapter 1: Introduction
      1. What’s in This Book?
        1. Who Is This Book for?
      2. Requirements
      3. About SpriteBuilder
        1. Why Use SpriteBuilder?
      4. About Cocos2D
      5. About Apportable
      6. About Program Versions
        1. About Xcode Versions
      7. About the Example Projects
        1. Example Projects Mapped to Chapters
      8. About Deployment Targets
      9. Table of Contents
        1. Chapter 1—Introduction
        2. Chapter 2—Laying the Groundwork
        3. Chapter 3—Controlling and Scrolling
        4. Chapter 4—Physics and Collisions
        5. Chapter 5—Timelines and Triggers
        6. Chapter 6—Menus and Popovers
        7. Chapter 7—MainScene and GameState
        8. Chapter 8—Selecting and Unlocking Levels
        9. Chapter 9—Physics Joints
        10. Chapter 10—Soft-Body Physics
        11. Chapter 11—Audio and Labels
        12. Chapter 12—Visual Effects and Animations
        13. Chapter 13—Porting to Android
        14. Chapter 14—Debugging and Best Practices
      10. Before You Get Started
    2. Chapter 2: Laying the Groundwork
      1. Creating a SpriteBuilder Project
      2. The SpriteBuilder Project’s Xcode Project
      3. First Scene, First Code
        1. Creating the GameScene
        2. Reviewing the Node Library
        3. Creating a Button
        4. Changing the Scene on Button Tap
        5. Creating a Level Sub File Node
        6. Adding the Player Sprite
      4. Summary
    3. Chapter 3: Controlling and Scrolling
      1. Touch and Go: Moving the Player
        1. Finding the Player Node by Its Name
        2. Assigning the Level-Node ivar
        3. Moving the Player with CCActionMoveTo
      2. Scrolling the Level
        1. Scheduling Updates
        2. Moving the Level Node in the Opposite Direction
      3. Parallax Scrolling
        1. Adding a Background CCB
        2. Adding the main Background Sprite
        3. Working with Images
        4. Adding Additional Background Layers
        5. Adding SpriteSheets for Background Graphics
        6. Designing the Background Layers
        7. Prepare to Parallax in 3, 2, 1...
      4. Summary
    4. Chapter 4: Physics & Collisions
      1. Player Physics
        1. Enabling Physics for the Player Sprite
        2. Move and Rotate Actions Conflict with Physics
        3. Moving the Player Through Physics
        4. Expose Design Values as Custom Properties
      2. Constructing the Level Physics
        1. Changing Gravity
        2. Interlude: Dealing with Lost Bodies
        3. Creating Static Level Borders
        4. Interlude: Physics Debug Drawing
      3. Collision Callback Methods
        1. Implementing the Collision Delegate Protocol
        2. Collision Types and Callback Parameter Names
        3. Ignoring Collisions with Categories and Masks
      4. Letting the Player Leave
        1. Creating an Exit Node
        2. Implementing the Exit Collision Callback
      5. Summary
    5. Chapter 5: Timelines & Triggers
      1. What Are Timelines and Keyframes?
        1. Using the Timeline Editor
        2. Adding Keyframes
      2. Keyframe Animations for Physics Nodes
        1. Adding the Gear and Saw
        2. Animating the Gear and Saw
        3. Adding Gears and Saws to the Level
      3. How Not to Autoplay Animations
        1. Editing Timelines to Uncheck Autoplay
        2. Playing Animations Programmatically
        3. Animation Playback Completion Callback
      4. Triggering Animations on Collision
        1. Adding Trigger Targets to the Level
        2. Creating a Trigger CCB
        3. Adding Triggers to the Level
        4. Creating the Trigger Class
        5. Programming the Trigger Class
      5. Summary
    6. Chapter 6: Menus & Popovers
      1. Static In-game Menus
        1. Adding Menu Graphics
        2. Adding a Static Game Menu Layer
      2. Programming the GameMenuLayer
        1. Implementing and Confirming Code Connections
        2. Assigning a GameScene Reference to GameMenuLayer
        3. Showing and Removing Popover Menus
      3. Pausing the Game
        1. Creating the Pause Menu Popover
        2. Changing Scenes with SceneManager
        3. Adding a Callbacks Keyframe
        4. Animating the Pause Menu on Resume
        5. Interlude: Pausing the Game When It Enters the Background
      4. Killing the Player
        1. Creating a “Game Over” Popover
        2. Showing the “Game Over” Popover
        3. Interlude: Fixing the Initial Scroll Position
      5. Summary
  12. Part II: Getting Down to Business with SpriteBuilder
    1. Chapter 7: Main Scene and Game State
      1. Main Scene Background
        1. Designing the Background Images
        2. Designing the Background CCB
        3. Animating the Background
        4. Launching with the Menu
      2. Main Scene Logo and Buttons
        1. Designing Logo and Buttons
        2. Animating Logo and Buttons
        3. Adding the Buttons to MainScene
      3. Settings Menu
        1. Designing the Settings Menu with Box Layout
        2. Changing the Slider Visuals
        3. Connecting the Sliders
        4. Dismissing the Settings Popover
        5. Persisting Game States
      4. Summary
    2. Chapter 8: Selecting and Unlocking Levels
      1. Adding the Content Node
      2. Adding the Scroll View Node
      3. Showing the Scroll View Popover
      4. Designing the Scroll View Content Node
      5. Unlocking Levels
      6. Highlighting Level Buttons
      7. Closing the Level-Selection Popover
      8. Loading Levels
      9. Adding a Dummy Level
      10. Winning Levels
      11. Adding More Levels
      12. Counting Level Files
      13. Showing the Correct Level-Selection Page
      14. Implementing Scroll View Delegate Methods
      15. Summary
    3. Chapter 9: Physics Joints
      1. What Are Joints?
      2. Types of Joints
      3. Creating a Chain
        1. Setting Up the Chain Sprites
        2. Adding Pivot Joints to the Chain
        3. Editing Common Joint Properties
        4. Editing Pivot-Joint Properties
        5. Connecting the Chain Elements
      4. Creating a Rope
        1. Turning the Chain into a Rope
        2. Adding Ropes and Chains to the Level
      5. Fixing Chain and Rope Collisions
        1. Minimizing the Risk of Physics Bodies “Exploding”
        2. Defining the Collision Categories
        3. Editing Collision Categories and Masks
        4. Variations of Collision Behavior
      6. Creating a Springboard
        1. All the Same: Springs, Slings, and Bows
        2. Designing the Springboard
        3. Adding Joints to the Springboard
        4. Testing the Springboard for the First Time
        5. Blocking the Spring’s Movement
        6. Adding a Spring Lock
        7. Releasing the Spring Lock
      7. Breaking Joints and Motors
        1. Breaking Force Example
        2. Motor Example
      8. Summary
    4. Chapter 10: Soft-Body Physics
      1. Rigid Bodies vs. Soft Bodies
      2. Configuring the Soft-Body Player
        1. Creating the New Player CCB
        2. Adding Center and Circumference Bodies
        3. Finding Points on the Circumference of a Circle
        4. Positioning Nodes on the Circle’s Circumference
      3. Moving and Drawing the Soft-Body Player
        1. Moving the Soft-Body Player
        2. Setting Up Vertices and Texture Coordinates
        3. Drawing the Texture with CCRenderer
      4. Playing Me Softly. . .
        1. Connecting the Circumference Bodies
        2. Increasing the Player’s Bounciness
        3. Connecting the Center Node
      5. Improving the Soft-Body Player
      6. Improving Texture Rendering
      7. Summary
  13. Part III: Now You’re a SpriteBuilder Pro!
    1. Chapter 11: Audio and Labels
      1. Introducing ObjectAL
      2. Using Audio Files in SpriteBuilder
        1. Importing Audio into SpriteBuilder
        2. Playing Sound Effects via the Timeline
      3. Programming Audio Playback
        1. Playing Long/Streaming Audio
        2. Playing Sound Effects
        3. Not Playing Sound Effects for a Short While
        4. Adjusting Audio Volumes
      4. Working with Labels
        1. Importing a Custom TrueType Font
        2. Editing Label Properties
        3. Adding a Credits String
        4. Localizing the Credits Label
        5. Localization Considerations
        6. TrueType vs. Bitmap Fonts
        7. Creating and Importing a Bitmap Font
        8. Using the Bitmap Font
      5. Summary
    2. Chapter 12: Visual Effects and Animations
      1. Sprite Frame Animations
        1. Creating a Sprite Frame Animation
        2. Adding Sprite Frame Animations to SoftBodyDrawNode
        3. Comparing Sprite Frames
      2. Particle Effects
        1. Limitations of Particle Effects
        2. Editing Particle System Parameters
      3. Shader Effects
        1. Adding an Effect Node
        2. Available Effects
        3. Shader-Effects Best Practices
      4. Summary
    3. Chapter 13: Porting to Android
      1. How Does Android Support Work?
      2. SpriteBuilder Android Documentation
      3. Installing Android Xcode Plugins
      4. Android Development Prerequisites
        1. Installing Android SDK Is Optional
        2. An Android Device Is Mandatory
        3. Connecting an Android Device via USB
        4. Enabling Developer Options
        5. Enabling USB Debugging
        6. Enabling Stay Awake
        7. Enabling OpenGL Stack Trace
      5. Confirming Deployment to Android
        1. Creating a New SpriteBuilder Project
        2. Selecting Scheme and Target Platform
        3. Build, Run, Transfer, Launch
        4. Troubleshooting
      6. Anatomy of a SpriteBuilder App
      7. Converting Bouncy Beast
        1. Fixing Compiler Errors
        2. Fixing Launch Problems
        3. Fixing Layout Issues
        4. Isolating Issues
      8. When to Port to Android
        1. Porting After Publishing on iOS
        2. Cross-Platform from the Start
      9. Summary
    4. Chapter 14: Debugging & Best Practices
      1. Logging Messages and Variables
      2. Adding an Exception Breakpoint (Xcode 5)
      3. Asserting Assumptions
      4. Adding Breakpoints
      5. Analyzing Your Code
      6. Cocos2D Framerate Stats
      7. Walking the Scene Graph
      8. Debugging Advice
      9. Frequently Encountered Issues
        1. Nil References
        2. Animation Playback Issues
        3. Audio Playback Issues
        4. Subclassing CCSprite for Sprite CCB Classes
        5. Can’t Edit the Custom Class Field
        6. Can’t Add Custom Properties to a Node
        7. Physics Collisions Are Not Working as Expected
        8. A Node Is Not Deallocating
      10. Summary
  14. Index