售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Cocos2d-x by Example Beginner's Guide Second Edition
Table of Contents
Cocos2d-x by Example Beginner's Guide Second Edition
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
Sections
Time for action – heading
What just happened?
Pop quiz – heading
Have a go hero – heading
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Installing Cocos2d-x
Downloading and installing Cocos2d-x
Time for action – downloading, downloading, downloading
What just happened?
Time for action – installing Cocos2d-x
What just happened?
Hello-x World-x
Time for action – creating an application
What just happened?
Time for action – deploying to Android
What just happened?
The folder structure
The iOS linkage classes
The AppDelegate class
The HelloWorldScene class
Who begets whom?
Finding more reference material
Time for action – running the test samples
What just happened?
The other tools
Summary
2. You Plus C++ Plus Cocos2d-x
Cocos2d-x – an introduction
Containers
The Director and cache classes
The other stuff
Do you know C++?
The class interface
Time for action – creating the interface
What just happened?
The class implementation
Time for action – creating the implementation
What just happened?
Instantiating objects and managing memory
Using static methods
The C++ and Cocos2d-x style
What you get with Ref
Summary
3. Your First Game – Air Hockey
Game configurations
Time for action – creating your game project
What just happened?
Time for action – laying down the rules
What just happened?
Supporting retina displays
Time for action – adding the image files
What just happened?
Time for action – adding retina support
What just happened?
Adding sound effects
Time for action – adding the sound files
What just happened?
Extending Sprite
Time for action – adding GameSprite.cpp
What just happened?
Time for action – implementing GameSprite
What just happened?
Have a go hero
The actual game scene
Time for action – coding the GameLayer interface
What just happened?
Time for action – implementing init()
What just happened?
Time for action – handling multitouches
What just happened?
Time for action – adding our main loop
What just happened?
Time for action – updating scores
What just happened?
Time for action – running the game in Android
What just happened?
Have a go hero
Summary
4. Fun with Sprites – Sky Defense
The game – sky defense
The game settings
The start project
Adding screen support for a universal app
Adding background music
Initializing the game
Using sprite sheets in Cocos2d-x
Batch drawing sprites
Time for action – creating SpriteBatchNode
What just happened?
Bitmap fonts in Cocos2d-x
Time for action – creating bitmap font labels
What just happened?
Time for action – adding the final screen sprites
What just happened?
Time for action – creating our object pools
What just happened?
Actions in a nutshell
Time for action – creating actions with Cocos2d-x
What just happened?
Animating a sprite in Cocos2d-x
Time for action – creating animations
What just happened?
Time to make our game tick!
Time for action – handling touches
What just happened?
Time for action – starting and restarting the game
What just happened?
Time for action – updating the game
What just happened?
Time for action – retrieving objects from the pool
What just happened?
Play the game!
Time for action – running the game in Android
What just happened?
Pop quiz – sprites and actions
Summary
5. On the Line – Rocket Through
The game – Rocket Through
The game settings
Play first, work later
The start project
Screen settings
So what are particles?
Time for action – creating particle systems
What just happened?
Creating the grid
Drawing primitives in Cocos2d-x
Time for action – let's do some drawing!
What just happened?
The rocket sprite
Time for action – updating our rocket sprite
What just happened?
Time for action – handling touches
What just happened?
The game loop
Time for action – adding the main loop
What just happened?
Kill and reset
Time for action – adding our resets and kills
What just happened?
Time for action – running the game in Android
What just happened?
Have a go hero
Summary
6. Quick and Easy Sprite – Victorian Rush Hour
The game – Victorian Rush Hour
The game settings
Rapid prototyping with Cocos2d-x
Time for action – creating placeholder sprites
What just happened?
The Player object
The Block object
The terrain object
Time for action – coding the player
What just happened?
Time for action – coding the Block object
What just happened?
Planning the Terrain class
Building the terrain object
Time for action – initializing our Terrain class
What just happened?
Time for action – initializing our Blocks object
What just happened?
Time for action – moving and resetting
What just happened?
Platform collision logic
Time for action – adding collision detection
What just happened?
Adding the controls
Time for action – handling touches
What just happened?
Time for action – coding the main loop
What just happened?
Summary
7. Adding the Looks – Victorian Rush Hour
Victorian Rush Hour – the game
New sprites
Animations
Texturing our buildings with sprites
Time for action – texturing the buildings
What just happened?
Containers within containers
Creating a parallax effect
Time for action – creating a parallax effect
What just happened?
Adding a menu to our game
Time for action – creating Menu and MenuItem
What just happened?
Adding a tutorial to our game
Time for action – adding a tutorial
What just happened?
Time for action – running the game in Android
What just happened?
Summary
8. Getting Physical – Box2D
Building a Box2D project with Cocos2d-x
Time for action – using debug draw in your Box2D project
What just happened?
So what is a physics engine?
Meeting Box2D
Meeting the world
Running the simulation
No Ref objects in Box2D
Meeting the bodies
Our game – MiniPool
Game settings
Sprite plus b2Body equal to b2Sprite
Creating the pool table
Creating edges
Creating the ball objects
Creating collision filters
Creating the cue
Creating a contact listener
The game controls
Time for action – adding the touch events
What just happened?
The main loop
Time for action – adding the main loop
What just happened?
Adding a timer to our game
Time for action – creating a timer
What just happened?
Time for action – running the game in Android
What just happened?
Have a go hero
Pop quiz
Summary
9. On the Level – Eskimo
The game – Eskimo
The game settings
Organizing the game
Using scenes in Cocos2d-x
Time for action – creating a scene transition
What just happened?
Time for action – creating transitions with a singleton Layer class
What just happened?
Loading external data from a .plist file
Time for action – creating a .plist file
What just happened?
Loading the level data
Time for action – retrieving data from the .plist file
What just happened?
Saving game data
Time for action – storing the completed levels
What just happened?
Using events in your game
Time for action – using the event dispatcher
What just happened?
Using the accelerometer
Time for action – reading accelerometer data
What just happened?
Reusing b2Bodies
Time for action – changing a b2Body fixture
What just happened?
Time for action – running the game in Android
What just happened?
Have a go hero
Summary
10. Introducing Lua!
So what is Lua like?
Debugging in Lua – the knights who say nil
The game – Stone Age
Time for action – creating or importing a project
What just happened?
Time for action – setting up our screen resolution
What just happened?
Time for action – creating a menu scene
What just happened?
Time for action – creating our game scene
What just happened?
Time for action – building the gems
What just happened?
Time for action – changing the grid with GridController
What just happened?
Time for action – swapping the gems and looking for matches
What just happened?
Time for action – collapsing the grid and repeating
What just happened?
Time for action – animating matches and collapses
What just happened?
Time for action – publishing the game with the Cocos IDE
What just happened?
Summary
A. Vector Calculations with Cocos2d-x
What are vectors?
The vector methods
Using ccp helper methods
Rotating the rocket around a point
Using the dot product of vectors
Moving from pixel-based speed to angular-based speed
B. Pop Quiz Answers
Chapter 4, Fun with Sprites – Sky Defense
Pop quiz – sprites and actions
Chapter 8, Getting Physical – Box2D
Pop quiz
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜