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