SlideShare ist ein Scribd-Unternehmen logo
1 von 70
Downloaden Sie, um offline zu lesen
iOS Game Development
with Cocos2D
Yaron Karasik
yaronkarasik@gmail.com @Greenwell
Thursday, June 21, 12
iOS Game Development
with Cocos2D
Part 1: Why Cocos2D?
Part 2: Cocos2D Basics
Part 3: Let’s build a Cocos2D game
Thursday, June 21, 12
Part 1:
Why Cocos2D?
Thursday, June 21, 12
Meet Cocos2D for iPhone
★ Open source iOS game development framework
★ Developed by Ricardo Quesada, acqui-hired by
Zynga (2011)
★ Stable v1.1 Based on OpenGL ES 1.1
★ Beta v2.0 Based on OpenGL ES 2.0
★ 3,500+ iOS games shipped
Thursday, June 21, 12
The Cocos2D Family
Cocos2d-Android
(Java)
Cocos2d-X
iPhone/Android (C++)
Cocos2d-Mac
(Obj-C)
Cocos2d-XNA
Windows Phone 7 (C#)
Cocos2d-HTML5
Web (Javascript)
Cocos3D
(Obj-C)
Thursday, June 21, 12
Proven Success
Thursday, June 21, 12
Great Effort-Flexibility Balance
0
100
Effort
Flexibility
Cocos2D/Sparrow
Unity/Corona
Direct OpenGL/
CoreGraphics
Thursday, June 21, 12
Cross Device, Cross Resolution
Thursday, June 21, 12
Active Ecosystem
Thursday, June 21, 12
And most importantly..
Tons of great features for games
SceneTransitionsSprite Sheets
Effects:
Lense, Ripple,Wave..
Actions:
Move, Rotate, Scale..
Integrated Physics Engines
Sound Support
Tile Map Support
Text RenderingParticle Systems
Parallax Scrolling
Shaders (v2.0)Ribbons
Thursday, June 21, 12
Part 2:
Cocos2D Basics
Thursday, June 21, 12
Basic Cocos2D Concepts
Director
Thursday, June 21, 12
Basic Cocos2D Concepts
Director
Scenes
Thursday, June 21, 12
Basic Cocos2D Concepts
Director
Scenes
Layers
Thursday, June 21, 12
Basic Cocos2D Concepts
Director
Scenes
Layers
Sprites
Thursday, June 21, 12
Director & Scenes
Intro Main Menu Level I Level 2 Victory
Options
High Scores
LossDirector
★ Game made up of “game screens” called Scenes
★ Each Scene can be considered a separate app
★ Director handles main window and executes Scenes
Thursday, June 21, 12
Layers
★ Each Scene contains several full screen Layers
★ Layers contain Sprites which are the game elements
★ Layers useful for Controls, Background, Labels, Menus.
Thursday, June 21, 12
Nodes
Nodes are anything that gets drawn or contains
things that get drawn (= Scene, Layer, Sprite)
Can: ★ Contain other Nodes
★ Schedule periodic callbacks
★ Execute Actions
Thursday, June 21, 12
Sprites in Action
Create
CCSpriteFrame* spriteFrame = [[CCSpriteFrameCache sharedSpriteFrameCache]
spriteFrameByName:@"sprite.png"];
CCSprite* sprite = [CCSprite spriteWithSpriteFrame:spriteFrame];
Thursday, June 21, 12
Sprites in Action
Add to Layer
sprite.position = ccp(x, y);
[layer addChild:sprite z:5 tag:666];
(0,0)
winSize.height
winSize.width
(x,y) at anchor point
Thursday, June 21, 12
Sprites in Action
Move
CCMoveTo *moveToAction = [CCMoveTo actionWithDuration:duration
position:newPosition];
[sprite runAction:moveToAction];
Properties can be transformed directly or through actions
Thursday, June 21, 12
Sprites in Action
Scale/Rotate
CCScaleTo *scaleToAction = [CCScaleTo actionWithDuration:duration scale:scale];
CCRotateBy *rotateByAction = [CCRotateBy actionWithDuration:duration angle:angle];
CCSequence *sequence = [CCSequence actions:scaleToAction, rotateByAction, nil];
[sprite runAction:sequence];
Thursday, June 21, 12
Sprites in Action
Animate
CCAnimation* animation = [[CCAnimationCache sharedAnimationCache]
animationByName:@"animation"];
CCAnimate* animateAction = [CCAnimate actionWithAnimation:animation];
[sprite runAction:animateAction];
Thursday, June 21, 12
Sprites in Action
Schedule Updates
[scene schedule:@selector(updateSprite:) interval:interval];
Thursday, June 21, 12
Actions
Can be performed on Sprites or any Node
Basic Move, Scale, Rotate, Bezier, Hide, Fade,Tint..
Composition Sequence, Repeat, Spawn, RepeatForever..
Ease Ease, EaseExponential, EaseBounce..
Effects Lens, Liquid, Ripple, Shaky,Twirl,Waves..
Special CallFunc, Follow..
Thursday, June 21, 12
Spritesheets
★ Added as a child to the layer
★ Created withTexturePacker or Zwoptex
★ Memory considerations, 16bit images, .pvr.ccz
Thursday, June 21, 12
Controls
★ Implement directly based on CCStandardTouchDelegate
★ Can use UIGestureRecognizer classes
★ Open source implementations of joypad/buttons available
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
Thursday, June 21, 12
Let’s Make a Game!
Part 3:
Thursday, June 21, 12
Let’s Make a Game!
..but ïŹrst we need a story, graphics, music and sfx :)
Part 3:
Thursday, June 21, 12
Because he likes to kill paratroopers
Para-Shoot
Thursday, June 21, 12
Graphics
Benjamin Radchek Sprites by The_Protoganist and _Allen_
http://www.freewebs.com/teh_pro/sprites.htm
Thursday, June 21, 12
Music & SFX
Explosive Attack by McTricky @ Sakari InïŹnity
http://www.sakari-inïŹnity.net/author/McTricky
Background music, shoot sound, death sound
Thursday, June 21, 12
Music & SFX
Explosive Attack by McTricky @ Sakari InïŹnity
http://www.sakari-inïŹnity.net/author/McTricky
Background music, shoot sound, death sound
Thursday, June 21, 12
Sneak Peek
Thursday, June 21, 12
Steps for making Para-Shoot
Application Setup
Step 1: Adding Background
Step 2: Adding Our Hero
Step 3: Adding Bad Guys (Game Logic)
Step 4: Killing Bad Guys (Adding UI)
Step 5: Check for Bad Guy Death
Step 6: Animating Our Hero
Step 7: Animating Bad Guys Dying
Step 8: Adding Body Count
Step 9: Adding Sound & Music
Thursday, June 21, 12
New Cocos2D Project
Thursday, June 21, 12
@interface HelloWorldLayer : CCLayer
{
! // Player sprite
! CCSprite *_player;
// Target and bullet sprite arrays
! NSMutableArray *_targets;
NSMutableArray *_bullets;
! // Body count counter and isShooting flag
int _bodyCount;
BOOL _isShooting;
!
! // For body count label
! CCLabelTTF *_labelTitle;
! CCLabelTTF *_labelCount;
}
HelloWorldScene.h
Thursday, June 21, 12
HelloWorldScene.m
// Create the new scene including this layer
+(id) scene
{
! // Create the scene
! CCScene *scene = [CCScene node];
!
! // Create the layer
! HelloWorldLayer *layer = [HelloWorldLayer node];
!
! // add layer as a child to scene
! [scene addChild: layer];
!
! // return the scene
! return scene;
}
Thursday, June 21, 12
Hello World
Thursday, June 21, 12
Step 1:Adding Background
(In init)
// Get the window size to place elements
CGSize winSize = [[CCDirector sharedDirector] winSize];
// Add the background image
CCSprite *background = [CCSprite spriteWithFile:@"background.png"];
background.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:background z:0];
Thursday, June 21, 12
Step 1:Adding Background
Thursday, June 21, 12
Step 2:Adding Our Hero
(In init)
// Load the sprite sheet
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode
batchNodeWithFile:@"parashoot.pvr.ccz"];
[self addChild:batchNode];
// Load the sprites into the shareSpriteFrameCache
[[CCSpriteFrameCache sharedSpriteFrameCache]
addSpriteFramesWithFile:@"parashoot.plist"];
Preload the spritesheet
Thursday, June 21, 12
Step 2:Adding Our Hero
// Add the player sprite
CCSpriteFrame* playerFrame = [[CCSpriteFrameCache sharedSpriteFrameCache]
spriteFrameByName:@"player_01.png"];
_player = [CCSprite spriteWithSpriteFrame:playerFrame];
_player.position = ccp(_player.contentSize.width/2 + 10, winSize.height/2);
[self addChild:_player z:1];
Add the hero sprite
Thursday, June 21, 12
Step 2:Adding Our Hero
Thursday, June 21, 12
Step 3:Adding Bad Guys (Game Logic)
(in init)
[self schedule:@selector(addTarget:) interval:1.0f];
Schedule a new target every second
Thursday, June 21, 12
// Create a new enemy
-(void)addTarget:(ccTime)dt {
// Create the target sprite
CCSpriteFrame *targetFrame = [[CCSpriteFrameCache sharedSpriteFrameCache]
spriteFrameByName:@"target.png"];
!CCSprite *target = [CCSprite spriteWithSpriteFrame:targetFrame];
// Add the target to the layer and the array
! [self addChild:target];
! [_targets addObject:target];
Step 3:Adding Bad Guys (Game Logic)
Create a sprite for the target
Thursday, June 21, 12
Step 3:Adding Bad Guys (Game Logic)
! // Determine where to spawn the target along the X axis
! CGSize winSize = [[CCDirector sharedDirector] winSize];
// Find a random X for the target in the right half of the screen
! int minX = winSize.width/2;
! int maxX = winSize.width - target.contentSize.width;
! int rangeX = maxX - minX;
! int actualX = (arc4random() % rangeX) + minX;
target.position = ccp(actualX, 320);
target.anchorPoint = ccp(0, 0);
! // Determine speed of the target
! int minDuration = 2.0;
! int maxDuration = 4.0;
! int rangeDuration = maxDuration - minDuration;
! int actualDuration = (arc4random() % rangeDuration) + minDuration;
Generate a random x position for the target
Thursday, June 21, 12
Step 3:Adding Bad Guys (Game Logic)
// Create and run the actions
CCMoveTo* moveTarget = [CCMoveTo actionWithDuration:actualDuration
! ! ! position:ccp(actualX, -target.contentSize.height/2)];
CCCallFuncN* actionForTargetMoveDidFinish = [CCCallFuncN
actionWithTarget:self selector:@selector(targetMoveFinished:)];
[target runAction:[CCSequence actions:moveTarget, actionForTargetMoveDidFinish, nil]];
Create a move action for the target with a
callback when reaching the bottom
Thursday, June 21, 12
Step 3:Adding Bad Guys (Game Logic)
// Method for removing a target that has died or reached the
bottom
-(void)targetMoveFinished:(id)sender {
! CCSprite *target = (CCSprite *)sender;
[self removeChild:target cleanup:YES];
! [_targets removeObject:target];
}
Add the callback method for a target that
dies or reaches the bottom
Thursday, June 21, 12
Step 3:Adding Bad Guys (Game Logic)
Thursday, June 21, 12
Step 4: Killing Bad Guys (Adding UI)
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
! // Choose one of the touches to work with
! UITouch *touch = [touches anyObject];
! CGPoint location = [touch locationInView:[touch view]];
! location = [[CCDirector sharedDirector] convertToGL:location];
!
if (!_isShooting) {
_isShooting = YES;
Detect the touch
Thursday, June 21, 12
Step 4: Killing Bad Guys (Adding UI)
// Create the bullet
CCSpriteFrame* bulletFrame = [[CCSpriteFrameCache sharedSpriteFrameCache]
spriteFrameByName:@"bullet.png"];
CCSprite* bulletSprite = [CCSprite spriteWithSpriteFrame:bulletFrame];
bulletSprite.position = _player.position;
// Bullet actions
CCCallFuncN* actionForRemoveBullet = [CCCallFuncN actionWithTarget:self
selector:@selector(removeBullet:)];
CCMoveBy* bulletMoveBy = [CCMoveBy actionWithDuration:1.0f
position:ccp(winSize.width, 0)];
[bulletSprite runAction:[CCSequence actionOne:bulletMoveBy
two:actionForRemoveBullet]];
// Add bullet to layer and array
[self addChild:bulletSprite];
[_bullets addObject:bulletSprite];
Create the bullet
Thursday, June 21, 12
Step 4: Killing Bad Guys (Adding UI)
Thursday, June 21, 12
Step 5: Check for Bad Guy Death
-(void)update:(ccTime)dt {
CCSprite* bulletToRemove = nil;
for (CCSprite *bullet in _bullets) {
for (CCSprite* target in _targets) {
CGRect targetBox = CGRectMake(target.position.x, target.position.y,
[target boundingBox].size.width, [target boundingBox].size.height);
// Check if bullet is in the target's bounding box
if (CGRectContainsPoint(targetBox, bullet.position)) {
// Animate target death and remove target
bulletToRemove = bullet;
}
}
}
// Remove bullet if target was hit
if (bulletToRemove != nil) {
[self removeChild:bulletToRemove cleanup:YES];
[_bullets removeObject:bulletToRemove];
}
}
Thursday, June 21, 12
Step 5: Check for Bad Guy Death
Thursday, June 21, 12
Step 6:Animating Our Hero
(In init)
// Load the animation for player
NSMutableArray *animFrames1 = [NSMutableArray array];
for (int i = 1; i < 12; i++) {
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"player_%02d.png",i]];
! [animFrames1 addObject:frame];
}
[[CCAnimationCache sharedAnimationCache] addAnimation:[CCAnimation
animationWithFrames:animFrames1 delay:FRAME_DELAY] name:@"player"];!
Preload the animation from the spritesheet
Thursday, June 21, 12
Step 6:Animating Our Hero
(In ccTouchesEnded)
// Actions for shooting animation
CCCallFunc* actionForShootDidEnd = [CCCallFunc actionWithTarget:self
selector:@selector(shootDidEnd)];
CCAnimation* playerShootAnimation = [[CCAnimationCache sharedAnimationCache]
animationByName:@"player"];
CCAnimate* shootAnimate = [CCAnimate actionWithAnimation:playerShootAnimation];
[_player runAction:[CCSequence actionOne:shootAnimate two:actionForShootDidEnd]];
Animate the hero when shooting
Thursday, June 21, 12
Step 6:Animating Our Hero
Thursday, June 21, 12
Step 7:Animating Bad Guys Dying
(in update)
// Set up actions for animation and target removal
CCCallFuncN* actionForDeathDidFinish = [CCCallFuncN actionWithTarget:self
selector:@selector(targetMoveFinished:)];
CCAnimate* deathAnimation = [CCAnimate actionWithAnimation:[[CCAnimationCache
sharedAnimationCache] animationByName:@"death"] restoreOriginalFrame:NO];
[target runAction:[CCSequence actionOne:deathAnimation two:actionForDeathDidFinish]];
Thursday, June 21, 12
Step 7:Animating Bad Guys Dying
Thursday, June 21, 12
Step 8:Adding Body Count
(In init)
NSString* bodyCountString = [NSString stringWithFormat:@"%d", _bodyCount];
_labelCount = [CCLabelTTF labelWithString:bodyCountString fontName:@"Arial"
fontSize:16];
_labelCount.color = ccc3(0,0,0);
_labelCount.position = ccp(110, winSize.height - 16);
[self addChild:_labelCount z:2];
(In ccTouchesEnded)
_bodyCount++;
NSString* bodyCountString = [NSString stringWithFormat:@"%d", _bodyCount];!
[_labelCount setString:bodyCountString];
Thursday, June 21, 12
Step 8:Adding Body Count
Thursday, June 21, 12
Step 9:Adding Sound & Music
(In init)
! // Start background music, set lower volume
! SimpleAudioEngine.sharedEngine.backgroundMusicVolume = 0.4f;
! [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"explosive_attack.mp3"];
(In ccTouchesEnded)
! // Play sound effect on every shot and on death
! [[SimpleAudioEngine sharedEngine] playEffect:@"shot.wav"];
! [[SimpleAudioEngine sharedEngine] playEffect:@"death.wav"];
Thursday, June 21, 12
Step 9:Adding Sound & Music
Thursday, June 21, 12
Let’s Play!
Thursday, June 21, 12
Para-Shoot 2.0
Enemies can move and attack
Joypad + HUD
Move our hero
Different weapons, power ups and health
Game menu and high scores
Levels
Save/Load Game
Refactor code (More scenes and layers)
Thursday, June 21, 12
Refactoring Para-Shoot
Intro Main Menu Level X Victory
Options
High Score
Loss
Level X Background Player Bad Guys Joypad/HUD
Scenes:
Layers:
Thursday, June 21, 12
More stuff to explore
★ Physics Engines - Chipmunk and Box2D
★ Particle System
★ Tilemaps
★ Menu Interface
Thursday, June 21, 12
Where can you learn more
Cocos2D Demo Library (Comes with Cocos)
Wiki: http://cocos2d-iphone.org/wiki
Ray Wenderlich: http://www.raywenderlich.com
Steffen Itterheim: http://learn-cocos2d.com
SapusTongue Source Code: http://www.sapusmedia.com/sources
Thursday, June 21, 12
ThankYou!
Yaron Karasik
yaronkarasik@gmail.com
@Greenwell
Thursday, June 21, 12

Weitere Àhnliche Inhalte

Was ist angesagt?

Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...British Council
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNAMICTT Palma
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.UA Mobile
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196Mahmoud Samir Fayed
 
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)Grant Goodale
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision DetectionJenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
Windows Azure Storage
Windows Azure StorageWindows Azure Storage
Windows Azure Storagegoodfriday
 
Game age ppt
Game age pptGame age ppt
Game age pptAhmed Yousef
 
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±Kohki Miki
 
Scrollytelling
ScrollytellingScrollytelling
ScrollytellingBaron Watts
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overviewMICTT Palma
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5Mark Chang
 
Hive sqlçš„çŒ–èŻ‘èż‡çš‹
Hive sqlçš„çŒ–èŻ‘èż‡çš‹Hive sqlçš„çŒ–èŻ‘èż‡çš‹
Hive sqlçš„çŒ–èŻ‘èż‡çš‹Chen Chun
 

Was ist angesagt? (15)

Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
06 html5 and cocos2d-x
06   html5 and cocos2d-x06   html5 and cocos2d-x
06 html5 and cocos2d-x
 
The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196The Ring programming language version 1.7 book - Part 64 of 196
The Ring programming language version 1.7 book - Part 64 of 196
 
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Windows Azure Storage
Windows Azure StorageWindows Azure Storage
Windows Azure Storage
 
Game age ppt
Game age pptGame age ppt
Game age ppt
 
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±
watchOS 2でă‚ČăƒŒăƒ äœœăŁăŠăżăŸè©±
 
Scrollytelling
ScrollytellingScrollytelling
Scrollytelling
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5
 
Hive sqlçš„çŒ–èŻ‘èż‡çš‹
Hive sqlçš„çŒ–èŻ‘èż‡çš‹Hive sqlçš„çŒ–èŻ‘èż‡çš‹
Hive sqlçš„çŒ–èŻ‘èż‡çš‹
 

Ähnlich wie Basics cocos2d

Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
iOS Game Development with Cocos2D
iOS Game Development with Cocos2DiOS Game Development with Cocos2D
iOS Game Development with Cocos2DGreenwell
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Changwon National University
 
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial DetectionTomomi Imura
 
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3SICEF
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)noorcon
 
Get Into Sprite Kit
Get Into Sprite KitGet Into Sprite Kit
Get Into Sprite Kitwaynehartman
 
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Applitools
 
Tools for developing Android Games
 Tools for developing Android Games Tools for developing Android Games
Tools for developing Android GamesPlatty Soft
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kitBuƟra Deniz, CSM
 
Creating physics game in 1 hour
Creating physics game in 1 hourCreating physics game in 1 hour
Creating physics game in 1 hourLinkou Bian
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsNick Pruehs
 

Ähnlich wie Basics cocos2d (20)

Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
iOS Game Development with Cocos2D
iOS Game Development with Cocos2DiOS Game Development with Cocos2D
iOS Game Development with Cocos2D
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection
[JS Kongress 2016] KittyCam.js - Raspberry Pi Camera w/ Cat Facial Detection
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3
Webelinx - iOS development: earn 100k daily with 1h of coding #tnt3
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
Get Into Sprite Kit
Get Into Sprite KitGet Into Sprite Kit
Get Into Sprite Kit
 
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
 
Tools for developing Android Games
 Tools for developing Android Games Tools for developing Android Games
Tools for developing Android Games
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kit
 
Creating physics game in 1 hour
Creating physics game in 1 hourCreating physics game in 1 hour
Creating physics game in 1 hour
 
Cocos2d for beginners
Cocos2d for beginnersCocos2d for beginners
Cocos2d for beginners
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
 

Mehr von sagaroceanic11

Module 21 investigative reports
Module 21 investigative reportsModule 21 investigative reports
Module 21 investigative reportssagaroceanic11
 
Module 20 mobile forensics
Module 20 mobile forensicsModule 20 mobile forensics
Module 20 mobile forensicssagaroceanic11
 
Module 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimesModule 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimessagaroceanic11
 
Module 18 investigating web attacks
Module 18 investigating web attacksModule 18 investigating web attacks
Module 18 investigating web attackssagaroceanic11
 
Module 17 investigating wireless attacks
Module 17 investigating wireless attacksModule 17 investigating wireless attacks
Module 17 investigating wireless attackssagaroceanic11
 
Module 04 digital evidence
Module 04 digital evidenceModule 04 digital evidence
Module 04 digital evidencesagaroceanic11
 
Module 03 searching and seizing computers
Module 03 searching and seizing computersModule 03 searching and seizing computers
Module 03 searching and seizing computerssagaroceanic11
 
Module 01 computer forensics in todays world
Module 01 computer forensics in todays worldModule 01 computer forensics in todays world
Module 01 computer forensics in todays worldsagaroceanic11
 
Virtualisation with v mware
Virtualisation with v mwareVirtualisation with v mware
Virtualisation with v mwaresagaroceanic11
 
Virtualisation overview
Virtualisation overviewVirtualisation overview
Virtualisation overviewsagaroceanic11
 
Virtualisation basics
Virtualisation basicsVirtualisation basics
Virtualisation basicssagaroceanic11
 
Introduction to virtualisation
Introduction to virtualisationIntroduction to virtualisation
Introduction to virtualisationsagaroceanic11
 
6 service operation
6 service operation6 service operation
6 service operationsagaroceanic11
 
5 service transition
5 service transition5 service transition
5 service transitionsagaroceanic11
 
4 service design
4 service design4 service design
4 service designsagaroceanic11
 
3 service strategy
3 service strategy3 service strategy
3 service strategysagaroceanic11
 
2 the service lifecycle
2 the service lifecycle2 the service lifecycle
2 the service lifecyclesagaroceanic11
 
1 introduction to itil v[1].3
1 introduction to itil v[1].31 introduction to itil v[1].3
1 introduction to itil v[1].3sagaroceanic11
 
Visual studio 2008 overview
Visual studio 2008 overviewVisual studio 2008 overview
Visual studio 2008 overviewsagaroceanic11
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.sagaroceanic11
 

Mehr von sagaroceanic11 (20)

Module 21 investigative reports
Module 21 investigative reportsModule 21 investigative reports
Module 21 investigative reports
 
Module 20 mobile forensics
Module 20 mobile forensicsModule 20 mobile forensics
Module 20 mobile forensics
 
Module 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimesModule 19 tracking emails and investigating email crimes
Module 19 tracking emails and investigating email crimes
 
Module 18 investigating web attacks
Module 18 investigating web attacksModule 18 investigating web attacks
Module 18 investigating web attacks
 
Module 17 investigating wireless attacks
Module 17 investigating wireless attacksModule 17 investigating wireless attacks
Module 17 investigating wireless attacks
 
Module 04 digital evidence
Module 04 digital evidenceModule 04 digital evidence
Module 04 digital evidence
 
Module 03 searching and seizing computers
Module 03 searching and seizing computersModule 03 searching and seizing computers
Module 03 searching and seizing computers
 
Module 01 computer forensics in todays world
Module 01 computer forensics in todays worldModule 01 computer forensics in todays world
Module 01 computer forensics in todays world
 
Virtualisation with v mware
Virtualisation with v mwareVirtualisation with v mware
Virtualisation with v mware
 
Virtualisation overview
Virtualisation overviewVirtualisation overview
Virtualisation overview
 
Virtualisation basics
Virtualisation basicsVirtualisation basics
Virtualisation basics
 
Introduction to virtualisation
Introduction to virtualisationIntroduction to virtualisation
Introduction to virtualisation
 
6 service operation
6 service operation6 service operation
6 service operation
 
5 service transition
5 service transition5 service transition
5 service transition
 
4 service design
4 service design4 service design
4 service design
 
3 service strategy
3 service strategy3 service strategy
3 service strategy
 
2 the service lifecycle
2 the service lifecycle2 the service lifecycle
2 the service lifecycle
 
1 introduction to itil v[1].3
1 introduction to itil v[1].31 introduction to itil v[1].3
1 introduction to itil v[1].3
 
Visual studio 2008 overview
Visual studio 2008 overviewVisual studio 2008 overview
Visual studio 2008 overview
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 

KĂŒrzlich hochgeladen

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...gurkirankumar98700
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

KĂŒrzlich hochgeladen (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Basics cocos2d

  • 1. iOS Game Development with Cocos2D Yaron Karasik yaronkarasik@gmail.com @Greenwell Thursday, June 21, 12
  • 2. iOS Game Development with Cocos2D Part 1: Why Cocos2D? Part 2: Cocos2D Basics Part 3: Let’s build a Cocos2D game Thursday, June 21, 12
  • 4. Meet Cocos2D for iPhone ★ Open source iOS game development framework ★ Developed by Ricardo Quesada, acqui-hired by Zynga (2011) ★ Stable v1.1 Based on OpenGL ES 1.1 ★ Beta v2.0 Based on OpenGL ES 2.0 ★ 3,500+ iOS games shipped Thursday, June 21, 12
  • 5. The Cocos2D Family Cocos2d-Android (Java) Cocos2d-X iPhone/Android (C++) Cocos2d-Mac (Obj-C) Cocos2d-XNA Windows Phone 7 (C#) Cocos2d-HTML5 Web (Javascript) Cocos3D (Obj-C) Thursday, June 21, 12
  • 8. Cross Device, Cross Resolution Thursday, June 21, 12
  • 10. And most importantly.. Tons of great features for games SceneTransitionsSprite Sheets Effects: Lense, Ripple,Wave.. Actions: Move, Rotate, Scale.. Integrated Physics Engines Sound Support Tile Map Support Text RenderingParticle Systems Parallax Scrolling Shaders (v2.0)Ribbons Thursday, June 21, 12
  • 16. Director & Scenes Intro Main Menu Level I Level 2 Victory Options High Scores LossDirector ★ Game made up of “game screens” called Scenes ★ Each Scene can be considered a separate app ★ Director handles main window and executes Scenes Thursday, June 21, 12
  • 17. Layers ★ Each Scene contains several full screen Layers ★ Layers contain Sprites which are the game elements ★ Layers useful for Controls, Background, Labels, Menus. Thursday, June 21, 12
  • 18. Nodes Nodes are anything that gets drawn or contains things that get drawn (= Scene, Layer, Sprite) Can: ★ Contain other Nodes ★ Schedule periodic callbacks ★ Execute Actions Thursday, June 21, 12
  • 19. Sprites in Action Create CCSpriteFrame* spriteFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"sprite.png"]; CCSprite* sprite = [CCSprite spriteWithSpriteFrame:spriteFrame]; Thursday, June 21, 12
  • 20. Sprites in Action Add to Layer sprite.position = ccp(x, y); [layer addChild:sprite z:5 tag:666]; (0,0) winSize.height winSize.width (x,y) at anchor point Thursday, June 21, 12
  • 21. Sprites in Action Move CCMoveTo *moveToAction = [CCMoveTo actionWithDuration:duration position:newPosition]; [sprite runAction:moveToAction]; Properties can be transformed directly or through actions Thursday, June 21, 12
  • 22. Sprites in Action Scale/Rotate CCScaleTo *scaleToAction = [CCScaleTo actionWithDuration:duration scale:scale]; CCRotateBy *rotateByAction = [CCRotateBy actionWithDuration:duration angle:angle]; CCSequence *sequence = [CCSequence actions:scaleToAction, rotateByAction, nil]; [sprite runAction:sequence]; Thursday, June 21, 12
  • 23. Sprites in Action Animate CCAnimation* animation = [[CCAnimationCache sharedAnimationCache] animationByName:@"animation"]; CCAnimate* animateAction = [CCAnimate actionWithAnimation:animation]; [sprite runAction:animateAction]; Thursday, June 21, 12
  • 24. Sprites in Action Schedule Updates [scene schedule:@selector(updateSprite:) interval:interval]; Thursday, June 21, 12
  • 25. Actions Can be performed on Sprites or any Node Basic Move, Scale, Rotate, Bezier, Hide, Fade,Tint.. Composition Sequence, Repeat, Spawn, RepeatForever.. Ease Ease, EaseExponential, EaseBounce.. Effects Lens, Liquid, Ripple, Shaky,Twirl,Waves.. Special CallFunc, Follow.. Thursday, June 21, 12
  • 26. Spritesheets ★ Added as a child to the layer ★ Created withTexturePacker or Zwoptex ★ Memory considerations, 16bit images, .pvr.ccz Thursday, June 21, 12
  • 27. Controls ★ Implement directly based on CCStandardTouchDelegate ★ Can use UIGestureRecognizer classes ★ Open source implementations of joypad/buttons available - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; Thursday, June 21, 12
  • 28. Let’s Make a Game! Part 3: Thursday, June 21, 12
  • 29. Let’s Make a Game! ..but ïŹrst we need a story, graphics, music and sfx :) Part 3: Thursday, June 21, 12
  • 30. Because he likes to kill paratroopers Para-Shoot Thursday, June 21, 12
  • 31. Graphics Benjamin Radchek Sprites by The_Protoganist and _Allen_ http://www.freewebs.com/teh_pro/sprites.htm Thursday, June 21, 12
  • 32. Music & SFX Explosive Attack by McTricky @ Sakari InïŹnity http://www.sakari-inïŹnity.net/author/McTricky Background music, shoot sound, death sound Thursday, June 21, 12
  • 33. Music & SFX Explosive Attack by McTricky @ Sakari InïŹnity http://www.sakari-inïŹnity.net/author/McTricky Background music, shoot sound, death sound Thursday, June 21, 12
  • 35. Steps for making Para-Shoot Application Setup Step 1: Adding Background Step 2: Adding Our Hero Step 3: Adding Bad Guys (Game Logic) Step 4: Killing Bad Guys (Adding UI) Step 5: Check for Bad Guy Death Step 6: Animating Our Hero Step 7: Animating Bad Guys Dying Step 8: Adding Body Count Step 9: Adding Sound & Music Thursday, June 21, 12
  • 37. @interface HelloWorldLayer : CCLayer { ! // Player sprite ! CCSprite *_player; // Target and bullet sprite arrays ! NSMutableArray *_targets; NSMutableArray *_bullets; ! // Body count counter and isShooting flag int _bodyCount; BOOL _isShooting; ! ! // For body count label ! CCLabelTTF *_labelTitle; ! CCLabelTTF *_labelCount; } HelloWorldScene.h Thursday, June 21, 12
  • 38. HelloWorldScene.m // Create the new scene including this layer +(id) scene { ! // Create the scene ! CCScene *scene = [CCScene node]; ! ! // Create the layer ! HelloWorldLayer *layer = [HelloWorldLayer node]; ! ! // add layer as a child to scene ! [scene addChild: layer]; ! ! // return the scene ! return scene; } Thursday, June 21, 12
  • 40. Step 1:Adding Background (In init) // Get the window size to place elements CGSize winSize = [[CCDirector sharedDirector] winSize]; // Add the background image CCSprite *background = [CCSprite spriteWithFile:@"background.png"]; background.position = ccp(winSize.width/2, winSize.height/2); [self addChild:background z:0]; Thursday, June 21, 12
  • 42. Step 2:Adding Our Hero (In init) // Load the sprite sheet CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"parashoot.pvr.ccz"]; [self addChild:batchNode]; // Load the sprites into the shareSpriteFrameCache [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"parashoot.plist"]; Preload the spritesheet Thursday, June 21, 12
  • 43. Step 2:Adding Our Hero // Add the player sprite CCSpriteFrame* playerFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"player_01.png"]; _player = [CCSprite spriteWithSpriteFrame:playerFrame]; _player.position = ccp(_player.contentSize.width/2 + 10, winSize.height/2); [self addChild:_player z:1]; Add the hero sprite Thursday, June 21, 12
  • 44. Step 2:Adding Our Hero Thursday, June 21, 12
  • 45. Step 3:Adding Bad Guys (Game Logic) (in init) [self schedule:@selector(addTarget:) interval:1.0f]; Schedule a new target every second Thursday, June 21, 12
  • 46. // Create a new enemy -(void)addTarget:(ccTime)dt { // Create the target sprite CCSpriteFrame *targetFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"target.png"]; !CCSprite *target = [CCSprite spriteWithSpriteFrame:targetFrame]; // Add the target to the layer and the array ! [self addChild:target]; ! [_targets addObject:target]; Step 3:Adding Bad Guys (Game Logic) Create a sprite for the target Thursday, June 21, 12
  • 47. Step 3:Adding Bad Guys (Game Logic) ! // Determine where to spawn the target along the X axis ! CGSize winSize = [[CCDirector sharedDirector] winSize]; // Find a random X for the target in the right half of the screen ! int minX = winSize.width/2; ! int maxX = winSize.width - target.contentSize.width; ! int rangeX = maxX - minX; ! int actualX = (arc4random() % rangeX) + minX; target.position = ccp(actualX, 320); target.anchorPoint = ccp(0, 0); ! // Determine speed of the target ! int minDuration = 2.0; ! int maxDuration = 4.0; ! int rangeDuration = maxDuration - minDuration; ! int actualDuration = (arc4random() % rangeDuration) + minDuration; Generate a random x position for the target Thursday, June 21, 12
  • 48. Step 3:Adding Bad Guys (Game Logic) // Create and run the actions CCMoveTo* moveTarget = [CCMoveTo actionWithDuration:actualDuration ! ! ! position:ccp(actualX, -target.contentSize.height/2)]; CCCallFuncN* actionForTargetMoveDidFinish = [CCCallFuncN actionWithTarget:self selector:@selector(targetMoveFinished:)]; [target runAction:[CCSequence actions:moveTarget, actionForTargetMoveDidFinish, nil]]; Create a move action for the target with a callback when reaching the bottom Thursday, June 21, 12
  • 49. Step 3:Adding Bad Guys (Game Logic) // Method for removing a target that has died or reached the bottom -(void)targetMoveFinished:(id)sender { ! CCSprite *target = (CCSprite *)sender; [self removeChild:target cleanup:YES]; ! [_targets removeObject:target]; } Add the callback method for a target that dies or reaches the bottom Thursday, June 21, 12
  • 50. Step 3:Adding Bad Guys (Game Logic) Thursday, June 21, 12
  • 51. Step 4: Killing Bad Guys (Adding UI) - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { ! // Choose one of the touches to work with ! UITouch *touch = [touches anyObject]; ! CGPoint location = [touch locationInView:[touch view]]; ! location = [[CCDirector sharedDirector] convertToGL:location]; ! if (!_isShooting) { _isShooting = YES; Detect the touch Thursday, June 21, 12
  • 52. Step 4: Killing Bad Guys (Adding UI) // Create the bullet CCSpriteFrame* bulletFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"bullet.png"]; CCSprite* bulletSprite = [CCSprite spriteWithSpriteFrame:bulletFrame]; bulletSprite.position = _player.position; // Bullet actions CCCallFuncN* actionForRemoveBullet = [CCCallFuncN actionWithTarget:self selector:@selector(removeBullet:)]; CCMoveBy* bulletMoveBy = [CCMoveBy actionWithDuration:1.0f position:ccp(winSize.width, 0)]; [bulletSprite runAction:[CCSequence actionOne:bulletMoveBy two:actionForRemoveBullet]]; // Add bullet to layer and array [self addChild:bulletSprite]; [_bullets addObject:bulletSprite]; Create the bullet Thursday, June 21, 12
  • 53. Step 4: Killing Bad Guys (Adding UI) Thursday, June 21, 12
  • 54. Step 5: Check for Bad Guy Death -(void)update:(ccTime)dt { CCSprite* bulletToRemove = nil; for (CCSprite *bullet in _bullets) { for (CCSprite* target in _targets) { CGRect targetBox = CGRectMake(target.position.x, target.position.y, [target boundingBox].size.width, [target boundingBox].size.height); // Check if bullet is in the target's bounding box if (CGRectContainsPoint(targetBox, bullet.position)) { // Animate target death and remove target bulletToRemove = bullet; } } } // Remove bullet if target was hit if (bulletToRemove != nil) { [self removeChild:bulletToRemove cleanup:YES]; [_bullets removeObject:bulletToRemove]; } } Thursday, June 21, 12
  • 55. Step 5: Check for Bad Guy Death Thursday, June 21, 12
  • 56. Step 6:Animating Our Hero (In init) // Load the animation for player NSMutableArray *animFrames1 = [NSMutableArray array]; for (int i = 1; i < 12; i++) { CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"player_%02d.png",i]]; ! [animFrames1 addObject:frame]; } [[CCAnimationCache sharedAnimationCache] addAnimation:[CCAnimation animationWithFrames:animFrames1 delay:FRAME_DELAY] name:@"player"];! Preload the animation from the spritesheet Thursday, June 21, 12
  • 57. Step 6:Animating Our Hero (In ccTouchesEnded) // Actions for shooting animation CCCallFunc* actionForShootDidEnd = [CCCallFunc actionWithTarget:self selector:@selector(shootDidEnd)]; CCAnimation* playerShootAnimation = [[CCAnimationCache sharedAnimationCache] animationByName:@"player"]; CCAnimate* shootAnimate = [CCAnimate actionWithAnimation:playerShootAnimation]; [_player runAction:[CCSequence actionOne:shootAnimate two:actionForShootDidEnd]]; Animate the hero when shooting Thursday, June 21, 12
  • 58. Step 6:Animating Our Hero Thursday, June 21, 12
  • 59. Step 7:Animating Bad Guys Dying (in update) // Set up actions for animation and target removal CCCallFuncN* actionForDeathDidFinish = [CCCallFuncN actionWithTarget:self selector:@selector(targetMoveFinished:)]; CCAnimate* deathAnimation = [CCAnimate actionWithAnimation:[[CCAnimationCache sharedAnimationCache] animationByName:@"death"] restoreOriginalFrame:NO]; [target runAction:[CCSequence actionOne:deathAnimation two:actionForDeathDidFinish]]; Thursday, June 21, 12
  • 60. Step 7:Animating Bad Guys Dying Thursday, June 21, 12
  • 61. Step 8:Adding Body Count (In init) NSString* bodyCountString = [NSString stringWithFormat:@"%d", _bodyCount]; _labelCount = [CCLabelTTF labelWithString:bodyCountString fontName:@"Arial" fontSize:16]; _labelCount.color = ccc3(0,0,0); _labelCount.position = ccp(110, winSize.height - 16); [self addChild:_labelCount z:2]; (In ccTouchesEnded) _bodyCount++; NSString* bodyCountString = [NSString stringWithFormat:@"%d", _bodyCount];! [_labelCount setString:bodyCountString]; Thursday, June 21, 12
  • 62. Step 8:Adding Body Count Thursday, June 21, 12
  • 63. Step 9:Adding Sound & Music (In init) ! // Start background music, set lower volume ! SimpleAudioEngine.sharedEngine.backgroundMusicVolume = 0.4f; ! [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"explosive_attack.mp3"]; (In ccTouchesEnded) ! // Play sound effect on every shot and on death ! [[SimpleAudioEngine sharedEngine] playEffect:@"shot.wav"]; ! [[SimpleAudioEngine sharedEngine] playEffect:@"death.wav"]; Thursday, June 21, 12
  • 64. Step 9:Adding Sound & Music Thursday, June 21, 12
  • 66. Para-Shoot 2.0 Enemies can move and attack Joypad + HUD Move our hero Different weapons, power ups and health Game menu and high scores Levels Save/Load Game Refactor code (More scenes and layers) Thursday, June 21, 12
  • 67. Refactoring Para-Shoot Intro Main Menu Level X Victory Options High Score Loss Level X Background Player Bad Guys Joypad/HUD Scenes: Layers: Thursday, June 21, 12
  • 68. More stuff to explore ★ Physics Engines - Chipmunk and Box2D ★ Particle System ★ Tilemaps ★ Menu Interface Thursday, June 21, 12
  • 69. Where can you learn more Cocos2D Demo Library (Comes with Cocos) Wiki: http://cocos2d-iphone.org/wiki Ray Wenderlich: http://www.raywenderlich.com Steffen Itterheim: http://learn-cocos2d.com SapusTongue Source Code: http://www.sapusmedia.com/sources Thursday, June 21, 12