SlideShare a Scribd company logo
Cocos2D
for iOS
By
Gibson Tang
Azukisoft Pte Ltd
22 – 12 - 2012
(The day after the Mayan prediction of the end of the world)
Binary size max is
                               64 kb, not 64 MB




Who Am I?
Mobile Developer since 2004

Ex Nokia Symbian

Ex J2ME developer

Currently Android and iPhone
developer
What is Cocos2D
Popular Objective-C game engine

Easy to use

Tons of support

Open source and free (Very important)
Cocos2D
Used in thousands of games

Creator of Cocos2D was acqui-hired by
Zynga

Yes, the Zynga whose stock is tanking now
What is Cocos2D
Has a lot of ports

Cocos2d-x for Android and cross platform

Cocos2d html5

Cocos2d for Blackberry etc
What is Cocos2D
http://www.cocos2d-iphone.org/download

Go download it now
Cocos2D
Director – The guy that calls the shots

Scenes – Director manages scenes

Layers – Scenes can comprise of 1 or more
layers

It is a game engine based on concept of
nodes
Cocos2D
Scenes
Think of a scene as a screen

So in a game, you may have a
• Starting scene
• Gameplay scene
• Results scene
etc
Layers
A scene can have > 1 layers

Think of a layer in the same vein as a layer in
a Photoshop PSD file

Same concept 
CCNode
CCNode is the base class that almost all
Cocos2D classes inherit from

This has common properties such as
- Position
- Z order
- Tag
- etc
Origin
The coordinate system starts from bottom
left of screen
    Y


          Hope you still remember
          your Cartesian Math



    0,0
                                X
Cocos2D
All classes and objects have the prefix ‘CC’

• CCSprite

• CCAction

• CCMoveBy

etc
CCSprite
An image object that loads in a png file

CCSprite *sprite = [CCSprite
spriteWithFile:@”man.png”];
Sprite Movement
Cocos2d has a vast array of actions

•   Movement
•   Scaling
•   Fading
•   Rotation
•   etc
•   http://www.cocos2d-iphone.org/api-
    ref/2.1.0/interface_c_c_action.html
Sprite
• After loading a sprite
• Need call the ‘add’ method
• To add the sprite to another sprite
• Or add to a scene
• Then the game engine handles
  the rendering for you
• Easy as Pie
Sprite Basics
CCSprite *sprite = [CCSprite
spriteWithFile:@”man.png”];
• [self addChild:sprite];
• [sprite runAction:[CCMoveTo
   actionWithDuration: 2.0f
   position:ccp(240, 320)]];

  This moves man.png to position 240, 320
  using 2 seconds
UIKit
So what happens if you want to integrate UIKit
element?

• Textfield

• Alertview

• Webview

Can you do that with Cocos2D?
UIKit
Yes, you can. Most common way is to add them
in using code

UIAlertView* alert_view = [[UIAlertView
alloc] initWithTitle:@”Title"
message:@"Your Message" delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert_view setDelegate:self];
[alert_view show];
[alert_view autorelease];
UIKit
UIKit
Yes, you can. Most common way is to add
them in using code

 UIView *myView = (UIView*) [[CCDirector
sharedDirector] openGLView];//get the view
    textField = [[UITextField alloc]
initWithFrame:CGRectMake(40, 168, 250, 40)];
    [myView addSubview:textField];
    [[[[CCDirector sharedDirector]openGLView]
window]addSubview:myView];
[myView setDelegate:self];
UIKit
UIKit
Yes, you can also add your xibs into Cocos2D

http://www.raywenderlich.com/4817/how
-to-integrate-cocos2d-and-uikit
Audio
• To play audio is very simple
• Just #import “SimpleAudioEngine.h”
• Then call the methods to play the audio
   • Background music
   • Effect
• mp3, wav, caf (Core Audio Format) files can be
  used
Audio
• [[SimpleAudioEngine sharedEngine]
  preloadEffect:@"sfx.wav"];
  //sfx.wav is the name of the sound file

• [[SimpleAudioEngine sharedEngine]
  playEffect:@"sfx.wav"];
  //play the audio file sfx.wav

• [[SimpleAudioEngine sharedEngine]
  playBackgroundMusic:@"bgm.mp3"];
  //play the bgm.mp3 background music
It’s Demo Time
I am going to show you how to create a
simple game

-   Game mechanics is simple
-   Tap the snails to squash them
-   Before they reach the end of the screen
-   It won’t be the next Angry Birds
-   But it’s a start
Download Code
• http://www.azukisoft.com/Helloi
  OSDevs.zip

More Related Content

What's hot

Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
Tiago Sousa
 
Multiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
Multiprocessor Game Loops: Lessons from Uncharted 2: Among ThievesMultiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
Multiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
Naughty Dog
 
Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .
YEONG-CHEON YOU
 
Level Design
Level DesignLevel Design
Level Design
Martin Sillaots
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
Juwal Bose
 
Unity 3D, A game engine
Unity 3D, A game engineUnity 3D, A game engine
Unity 3D, A game engine
Md. Irteza rahman Masud
 
Shader model 5 0 and compute shader
Shader model 5 0 and compute shaderShader model 5 0 and compute shader
Shader model 5 0 and compute shader
zaywalker
 
Horizon Zero Dawn: An Open World QA Case Study
Horizon Zero Dawn: An Open World QA Case StudyHorizon Zero Dawn: An Open World QA Case Study
Horizon Zero Dawn: An Open World QA Case Study
Guerrilla
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Philip Hammer
 
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
Gerke Max Preussner
 
NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017
Mark Kilgard
 
Unreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) PresentationUnreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) Presentation
Nitin Sharma
 
빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술
YEONG-CHEON YOU
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
Ki Hyunwoo
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
davidluzgouveia
 
OpenGL L04-Lighting
OpenGL L04-LightingOpenGL L04-Lighting
OpenGL L04-Lighting
Mohammad Shaker
 
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
Colin Barré-Brisebois
 
Building Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero DawnBuilding Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero Dawn
Guerrilla
 
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
강 민우
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shadingMinGeun Park
 

What's hot (20)

Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
Multiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
Multiprocessor Game Loops: Lessons from Uncharted 2: Among ThievesMultiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
Multiprocessor Game Loops: Lessons from Uncharted 2: Among Thieves
 
Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .
 
Level Design
Level DesignLevel Design
Level Design
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
 
Unity 3D, A game engine
Unity 3D, A game engineUnity 3D, A game engine
Unity 3D, A game engine
 
Shader model 5 0 and compute shader
Shader model 5 0 and compute shaderShader model 5 0 and compute shader
Shader model 5 0 and compute shader
 
Horizon Zero Dawn: An Open World QA Case Study
Horizon Zero Dawn: An Open World QA Case StudyHorizon Zero Dawn: An Open World QA Case Study
Horizon Zero Dawn: An Open World QA Case Study
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
 
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
 
NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017
 
Unreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) PresentationUnreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) Presentation
 
빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
 
OpenGL L04-Lighting
OpenGL L04-LightingOpenGL L04-Lighting
OpenGL L04-Lighting
 
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
 
Building Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero DawnBuilding Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero Dawn
 
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
[IGC 2016] 넷게임즈 김영희 - Unreal4를 사용해 모바일 프로젝트 제작하기
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading
 

Similar to Cocos2d for beginners

Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
Vinsol
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
Changwon National University
 
Cocos2d game programming 2
Cocos2d game programming 2Cocos2d game programming 2
Cocos2d game programming 2
Changwon National University
 
Iphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2DIphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2D
creagamers
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game development
Jerel Hass
 
Creating physics game in 1 hour
Creating physics game in 1 hourCreating physics game in 1 hour
Creating physics game in 1 hour
Linkou Bian
 
Cocos2d programming
Cocos2d programmingCocos2d programming
Cocos2d programming
Changwon National University
 
Cocos2d for i phone(second) copy
Cocos2d for i phone(second)   copyCocos2d for i phone(second)   copy
Cocos2d for i phone(second) copy
Arafat X
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
fsxflyer789Productio
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
Troy Miles
 
Android game development
Android game developmentAndroid game development
Android game development
dmontagni
 
Under Cocos 2 D Tree_mdevcon 2013
Under Cocos 2 D Tree_mdevcon 2013Under Cocos 2 D Tree_mdevcon 2013
Under Cocos 2 D Tree_mdevcon 2013
Wooga
 
Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013
Maxim Zaks
 
Introduction to Mobile Game Programming with Cocos2d-JS
Introduction to Mobile Game Programming with Cocos2d-JSIntroduction to Mobile Game Programming with Cocos2d-JS
Introduction to Mobile Game Programming with Cocos2d-JS
Troy Miles
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting Started
Hemant Chhapoliya
 
Targeting Android with Qt
Targeting Android with QtTargeting Android with Qt
Targeting Android with Qt
Espen Riskedal
 
CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012
Jesse Collis
 
Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayer
Jesse Collis
 
Demo creating-physics-game.
Demo creating-physics-game.Demo creating-physics-game.
Demo creating-physics-game.
sagaroceanic11
 
Processing for Android: Getting Started
Processing for Android: Getting StartedProcessing for Android: Getting Started
Processing for Android: Getting Started
PETER KIRN
 

Similar to Cocos2d for beginners (20)

Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
Cocos2d game programming 2
Cocos2d game programming 2Cocos2d game programming 2
Cocos2d game programming 2
 
Iphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2DIphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2D
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game development
 
Creating physics game in 1 hour
Creating physics game in 1 hourCreating physics game in 1 hour
Creating physics game in 1 hour
 
Cocos2d programming
Cocos2d programmingCocos2d programming
Cocos2d programming
 
Cocos2d for i phone(second) copy
Cocos2d for i phone(second)   copyCocos2d for i phone(second)   copy
Cocos2d for i phone(second) copy
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
 
Android game development
Android game developmentAndroid game development
Android game development
 
Under Cocos 2 D Tree_mdevcon 2013
Under Cocos 2 D Tree_mdevcon 2013Under Cocos 2 D Tree_mdevcon 2013
Under Cocos 2 D Tree_mdevcon 2013
 
Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013Under Cocos2D Tree @mdvecon 2013
Under Cocos2D Tree @mdvecon 2013
 
Introduction to Mobile Game Programming with Cocos2d-JS
Introduction to Mobile Game Programming with Cocos2d-JSIntroduction to Mobile Game Programming with Cocos2d-JS
Introduction to Mobile Game Programming with Cocos2d-JS
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting Started
 
Targeting Android with Qt
Targeting Android with QtTargeting Android with Qt
Targeting Android with Qt
 
CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012
 
Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayer
 
Demo creating-physics-game.
Demo creating-physics-game.Demo creating-physics-game.
Demo creating-physics-game.
 
Processing for Android: Getting Started
Processing for Android: Getting StartedProcessing for Android: Getting Started
Processing for Android: Getting Started
 

More from Azukisoft Pte Ltd

From Idea to App Store
From Idea to App StoreFrom Idea to App Store
From Idea to App Store
Azukisoft Pte Ltd
 
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensorModbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
Azukisoft Pte Ltd
 
Ohoh
OhohOhoh
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
Azukisoft Pte Ltd
 
Storyboard prototyping
Storyboard prototypingStoryboard prototyping
Storyboard prototyping
Azukisoft Pte Ltd
 
The good, bad and ugly of Digital Ocean vs AWS
The good, bad and ugly of Digital Ocean vs AWSThe good, bad and ugly of Digital Ocean vs AWS
The good, bad and ugly of Digital Ocean vs AWS
Azukisoft Pte Ltd
 
Presentation
PresentationPresentation
Presentation
Azukisoft Pte Ltd
 
Mobile Marketing Dec2009
Mobile Marketing Dec2009Mobile Marketing Dec2009
Mobile Marketing Dec2009
Azukisoft Pte Ltd
 

More from Azukisoft Pte Ltd (8)

From Idea to App Store
From Idea to App StoreFrom Idea to App Store
From Idea to App Store
 
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensorModbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
Modbus using Coreblue Bluetooth for iOS to connect to a hardware sensor
 
Ohoh
OhohOhoh
Ohoh
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
Storyboard prototyping
Storyboard prototypingStoryboard prototyping
Storyboard prototyping
 
The good, bad and ugly of Digital Ocean vs AWS
The good, bad and ugly of Digital Ocean vs AWSThe good, bad and ugly of Digital Ocean vs AWS
The good, bad and ugly of Digital Ocean vs AWS
 
Presentation
PresentationPresentation
Presentation
 
Mobile Marketing Dec2009
Mobile Marketing Dec2009Mobile Marketing Dec2009
Mobile Marketing Dec2009
 

Recently uploaded

The Gallery of Shadows, In the heart of a bustling city
The Gallery of Shadows, In the heart of a bustling cityThe Gallery of Shadows, In the heart of a bustling city
The Gallery of Shadows, In the heart of a bustling city
John Emmett
 
The Midnight Sculptor.pdf writer by Ali alsiad
The Midnight Sculptor.pdf writer by Ali alsiadThe Midnight Sculptor.pdf writer by Ali alsiad
The Midnight Sculptor.pdf writer by Ali alsiad
ali345alghlay
 
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
sbewyav
 
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
ytunuq
 
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdfUnlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
WHMCS Smarters
 
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen StageAbraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
DiaDan Holdings Ltd
 
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women MagazineTaylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
CIOWomenMagazine
 
Sara Saffari: Turning Underweight into Fitness Success at 23
Sara Saffari: Turning Underweight into Fitness Success at 23Sara Saffari: Turning Underweight into Fitness Success at 23
Sara Saffari: Turning Underweight into Fitness Success at 23
get joys
 
Sunny and Rishi 3 Written by Basak Serin
Sunny and Rishi 3 Written by Basak SerinSunny and Rishi 3 Written by Basak Serin
Sunny and Rishi 3 Written by Basak Serin
Basak24
 
Tom Cruise Daughter: An Insight into the Life of Suri Cruise
Tom Cruise Daughter: An Insight into the Life of Suri CruiseTom Cruise Daughter: An Insight into the Life of Suri Cruise
Tom Cruise Daughter: An Insight into the Life of Suri Cruise
greendigital
 
The Evolution and Impact of Tom Cruise Long Hair
The Evolution and Impact of Tom Cruise Long HairThe Evolution and Impact of Tom Cruise Long Hair
The Evolution and Impact of Tom Cruise Long Hair
greendigital
 
Audio Video equipment supplier in Gurgaon
Audio Video equipment supplier in GurgaonAudio Video equipment supplier in Gurgaon
Audio Video equipment supplier in Gurgaon
demoacsindia
 
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
x0l4b5ho
 
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girlsℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
meherkumarescorts
 
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
juliancopeman444
 
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
humbertogarsia692
 
SERV - Fun Things To Do In Overland Park
SERV - Fun Things To Do In Overland ParkSERV - Fun Things To Do In Overland Park
SERV - Fun Things To Do In Overland Park
SERV
 
Anasuya Sengupta Cannes 2024 Award Winner
Anasuya Sengupta Cannes 2024 Award WinnerAnasuya Sengupta Cannes 2024 Award Winner
Anasuya Sengupta Cannes 2024 Award Winner
Diwitya Bajwa
 
The Enigma of the Midnight Canvas, In the heart of Paris
The Enigma of the Midnight Canvas, In the heart of ParisThe Enigma of the Midnight Canvas, In the heart of Paris
The Enigma of the Midnight Canvas, In the heart of Paris
John Emmett
 
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girlsℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
moharsinghtrt1950
 

Recently uploaded (20)

The Gallery of Shadows, In the heart of a bustling city
The Gallery of Shadows, In the heart of a bustling cityThe Gallery of Shadows, In the heart of a bustling city
The Gallery of Shadows, In the heart of a bustling city
 
The Midnight Sculptor.pdf writer by Ali alsiad
The Midnight Sculptor.pdf writer by Ali alsiadThe Midnight Sculptor.pdf writer by Ali alsiad
The Midnight Sculptor.pdf writer by Ali alsiad
 
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
一比一原版(uw毕业证书)美国威斯康星大学麦迪逊分校毕业证如何办理
 
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
一比一原版(UCSF毕业证)旧金山分校毕业证如何办理
 
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdfUnlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
Unlocking the Secrets of IPTV App Development_ A Comprehensive Guide.pdf
 
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen StageAbraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
Abraham Laboriel Records ‘The Bass Walk’ at Evergreen Stage
 
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women MagazineTaylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
Taylor Swift: Conquering Fame, Feuds, and Unmatched Success | CIO Women Magazine
 
Sara Saffari: Turning Underweight into Fitness Success at 23
Sara Saffari: Turning Underweight into Fitness Success at 23Sara Saffari: Turning Underweight into Fitness Success at 23
Sara Saffari: Turning Underweight into Fitness Success at 23
 
Sunny and Rishi 3 Written by Basak Serin
Sunny and Rishi 3 Written by Basak SerinSunny and Rishi 3 Written by Basak Serin
Sunny and Rishi 3 Written by Basak Serin
 
Tom Cruise Daughter: An Insight into the Life of Suri Cruise
Tom Cruise Daughter: An Insight into the Life of Suri CruiseTom Cruise Daughter: An Insight into the Life of Suri Cruise
Tom Cruise Daughter: An Insight into the Life of Suri Cruise
 
The Evolution and Impact of Tom Cruise Long Hair
The Evolution and Impact of Tom Cruise Long HairThe Evolution and Impact of Tom Cruise Long Hair
The Evolution and Impact of Tom Cruise Long Hair
 
Audio Video equipment supplier in Gurgaon
Audio Video equipment supplier in GurgaonAudio Video equipment supplier in Gurgaon
Audio Video equipment supplier in Gurgaon
 
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
定制(mu毕业证书)美国迈阿密大学牛津分校毕业证学历证书原版一模一样
 
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girlsℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
ℂall Girls Lucknow (india) +91-7426014248 Lucknow ℂall Girls
 
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
欧洲杯赌球-欧洲杯赌球竞猜官网-欧洲杯赌球竞猜网站|【​网址​🎉ac10.net🎉​】
 
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
欧洲杯足彩-欧洲杯足彩下注网站-欧洲杯足彩投注网站|【​网址​🎉ac99.net🎉​】
 
SERV - Fun Things To Do In Overland Park
SERV - Fun Things To Do In Overland ParkSERV - Fun Things To Do In Overland Park
SERV - Fun Things To Do In Overland Park
 
Anasuya Sengupta Cannes 2024 Award Winner
Anasuya Sengupta Cannes 2024 Award WinnerAnasuya Sengupta Cannes 2024 Award Winner
Anasuya Sengupta Cannes 2024 Award Winner
 
The Enigma of the Midnight Canvas, In the heart of Paris
The Enigma of the Midnight Canvas, In the heart of ParisThe Enigma of the Midnight Canvas, In the heart of Paris
The Enigma of the Midnight Canvas, In the heart of Paris
 
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girlsℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
ℂall Girls Goa (india) +91-7426014248 Goa ℂall Girls
 

Cocos2d for beginners

  • 1. Cocos2D for iOS By Gibson Tang Azukisoft Pte Ltd 22 – 12 - 2012 (The day after the Mayan prediction of the end of the world)
  • 2. Binary size max is 64 kb, not 64 MB Who Am I? Mobile Developer since 2004 Ex Nokia Symbian Ex J2ME developer Currently Android and iPhone developer
  • 3. What is Cocos2D Popular Objective-C game engine Easy to use Tons of support Open source and free (Very important)
  • 4. Cocos2D Used in thousands of games Creator of Cocos2D was acqui-hired by Zynga Yes, the Zynga whose stock is tanking now
  • 5.
  • 6. What is Cocos2D Has a lot of ports Cocos2d-x for Android and cross platform Cocos2d html5 Cocos2d for Blackberry etc
  • 8. Cocos2D Director – The guy that calls the shots Scenes – Director manages scenes Layers – Scenes can comprise of 1 or more layers It is a game engine based on concept of nodes
  • 10. Scenes Think of a scene as a screen So in a game, you may have a • Starting scene • Gameplay scene • Results scene etc
  • 11. Layers A scene can have > 1 layers Think of a layer in the same vein as a layer in a Photoshop PSD file Same concept 
  • 12. CCNode CCNode is the base class that almost all Cocos2D classes inherit from This has common properties such as - Position - Z order - Tag - etc
  • 13. Origin The coordinate system starts from bottom left of screen Y Hope you still remember your Cartesian Math 0,0 X
  • 14. Cocos2D All classes and objects have the prefix ‘CC’ • CCSprite • CCAction • CCMoveBy etc
  • 15. CCSprite An image object that loads in a png file CCSprite *sprite = [CCSprite spriteWithFile:@”man.png”];
  • 16. Sprite Movement Cocos2d has a vast array of actions • Movement • Scaling • Fading • Rotation • etc • http://www.cocos2d-iphone.org/api- ref/2.1.0/interface_c_c_action.html
  • 17. Sprite • After loading a sprite • Need call the ‘add’ method • To add the sprite to another sprite • Or add to a scene • Then the game engine handles the rendering for you • Easy as Pie
  • 18. Sprite Basics CCSprite *sprite = [CCSprite spriteWithFile:@”man.png”]; • [self addChild:sprite]; • [sprite runAction:[CCMoveTo actionWithDuration: 2.0f position:ccp(240, 320)]]; This moves man.png to position 240, 320 using 2 seconds
  • 19. UIKit So what happens if you want to integrate UIKit element? • Textfield • Alertview • Webview Can you do that with Cocos2D?
  • 20. UIKit Yes, you can. Most common way is to add them in using code UIAlertView* alert_view = [[UIAlertView alloc] initWithTitle:@”Title" message:@"Your Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert_view setDelegate:self]; [alert_view show]; [alert_view autorelease];
  • 21. UIKit
  • 22. UIKit Yes, you can. Most common way is to add them in using code UIView *myView = (UIView*) [[CCDirector sharedDirector] openGLView];//get the view textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 168, 250, 40)]; [myView addSubview:textField]; [[[[CCDirector sharedDirector]openGLView] window]addSubview:myView]; [myView setDelegate:self];
  • 23. UIKit
  • 24. UIKit Yes, you can also add your xibs into Cocos2D http://www.raywenderlich.com/4817/how -to-integrate-cocos2d-and-uikit
  • 25. Audio • To play audio is very simple • Just #import “SimpleAudioEngine.h” • Then call the methods to play the audio • Background music • Effect • mp3, wav, caf (Core Audio Format) files can be used
  • 26. Audio • [[SimpleAudioEngine sharedEngine] preloadEffect:@"sfx.wav"]; //sfx.wav is the name of the sound file • [[SimpleAudioEngine sharedEngine] playEffect:@"sfx.wav"]; //play the audio file sfx.wav • [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"bgm.mp3"]; //play the bgm.mp3 background music
  • 27. It’s Demo Time I am going to show you how to create a simple game - Game mechanics is simple - Tap the snails to squash them - Before they reach the end of the screen - It won’t be the next Angry Birds - But it’s a start