Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d Game Development Blueprints

You're reading from   Cocos2d Game Development Blueprints Design, develop, and create your own successful iOS games using the Cocos2d game engine

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781783987887
Length 440 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jorge Jord√°n Jorge Jord√°n
Author Profile Icon Jorge Jord√°n
Jorge Jord√°n
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Sprites, Sounds, and Collisions 2. Explosions and UFOs FREE CHAPTER 3. Your First Online Game 4. Beat All Your Enemies Up 5. Scenes at the Highest Level 6. Physics Behavior 7. Jump and Run 8. Defend the Tower Index

Cocos2d v3.0

Cocos2d for iOS (http://www.cocos2d-iphone.org) is one of the most powerful and popular frameworks to develop 2D games with. Its popularity is due to its features: it's open source and 2D; has a wide and collaborative community; supports sprites, collisions, scenes, transitions, audio effects, actions, physics, and animations; and has a lot more features.

At the time of writing this book, the current version is Cocos2d v3.0, released a few months ago, so if you have previous experience with this framework, it is possible that you will find some differences and new features.

Pure Objective-C

The syntax has been improved so method names conform to conventions and the code is now better structured. Also, the C libraries have been removed so now we will use just the Core Foundation classes.

ARC

Previously, the new projects created in Cocos2d didn't use Automatic Reference Counting (ARC) by default, but you could enable ARC with a little refactoring process. Now you can forget all these headaches of retaining, releasing, and autoreleasing memory as v3 is ARC-only.

CCDirector

The former [CCDirector sharedDirector].winSize feature has been replaced by the new [CCDirector sharedDirector].viewSize feature.

CCLayer

CCNode has replaced CCLayer. Previously, CCLayer was used mainly to support for touch and accelerometer events but since every node inherits from CCResponder and has this ability, it's no longer needed. Now CCLayer can't be inherited to create new classes to represent scenes; instead of this class, you should use CCScene from now onward.

CCArray

In the first versions of Cocos2d, CCArray was used thanks to the speed it provided. However, this advantage is no longer the case and during Cocos2d v2, a lot of developers were recommending not to use this class to manage arrays. That's why it has been deprecated in this new version and is no longer available.

OALSimpleAudio

CocosDenshion's SimpleAudioEngine, an external class, previously supported sound and audio effects. From now, ObjectAL's OALSimpleAudio class has replaced SimpleAudioEngine. This new class is focused on doing what we need in a simple way, converting complex actions into easy tasks.

CCAction

Almost all the action classes have been renamed to something like CCActionNameAction; despite this, its syntax remains unaltered.

CCActionCallBlock

Good-bye CCCallBlock, hello CCActionCallBlock. Something similar to what happened to CCAction also happens to CCCallBlock; it has been renamed but its syntax remains unaltered.

Sequences

The former CCSequence class is now named CCActionSequence and the most important change in this case is that when passing the array of actions to the sequences, you don't have to pass a nil object as the last element.

Schedule update

In the previous version, you should execute scheduleUpdate in order to schedule the update method to be called every frame. This is not needed anymore; now you just need to implement the update method in the way you want to work.

Enabling touches

Touch handling is now performed by CCNode and therefore by its descendants. To enable it now, you will need to set userInteractionEnabled to TRUE and implement either touchBegan, touchMoved, touchEnded, or touchCancelled.

Accelerometer events

As with touches, to enable accelerometer events handling, you need to set userInteractionEnabled to TRUE and you will also need to add the Core Motion framework.

Physics

Unlike what happened in Cocos2d v2, physics are now based on Chipmunk. Previously, we had both Box2D and Chipmunk to implement physics, but now the only library will be Chipmunk.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image