SlideShare a Scribd company logo
1 of 56
Download to read offline
iOS
~
2d GameDev
Alain Hufkens - @hufkens!
CocoaHeadsBE - Hasselt - 2014-06-24
drinks sponsored by
• Geek Dad
• 15y programming
• Freelance
• Wee Taps
• CoderDojo
Intro
Agenda
• Game Engines
• SpriteKit
• SpriteBuilder / Cocos2D
• Q&A
2d Game engines
Cocos2d
• 2008
• Simple 2D game engine
• +10k games built with Cocos2D
• Bought by Zynga
• Spawned into Cocos2D-X
• Development stopped for a while
Cocos2D V1.x
Cocos2D V2.x
Sprite Kit
• 2013
• 2D Game Framework
• iOS7+ only
• Provided by Apple (since iOS7)
• Improved in iOS8
• Simple to prototype games
Sprite kit
Cocos2D V3
• 2014
• Cocos2D v3
• Spritebuilder
• Supported by Apportable
• 2D Game Development Suite
• Cross Platform & Native
Spritebuilder
Sprite kit
Scene graph
Scene
Background Foreground
HUD
Hero
Score
Bg Image
Tree
Tree
Game Loop
Game Loop
Node Classes
SKNode
SKEmitterNode
SKSpriteNode
SKLabelNode
SKShapeNodeSKScene
SKEffectsNode
SKCropNode
SKNode!
The base class!
• Used for grouping in node tree
@property SKNode *parent;

@property SKNode *children;
• Used for positioning itself and children
@property CGPoint position; // relative to parent

@property CGFloat zRotation; // radians

@property CGFloat xScale, yScale; // scaling
• Can control visibility
@property CGFloat alpha;

@property BOOL hidden;
• Can run actions
• Can be a physics body
Sprite Kit Nodes!
Node classes
Class Description
SKNode Parent class of all nodes
SKScene Root of the scene graph
SKSpriteNode! Renders a textured sprite
SKEmitterNode Generates and renders particles
SKLabelNode Renders a text string
SKVideoNode Plays video content
SKShapeNode Renders a shape
SKEffectNode Applies a Core Image filter to its children
SKCropNode Crops its children using a mask
Sprites & particles
• Draws a Sprite
• Can be a:
• color
• textured image
• Has a explicit size
SKSpriteNode
SKSpriteNode
SKSpriteNode!
Simple creation
SKSpriteNode *rocket =
[SKSpriteNode spriteNodeWithImageNamed:@"rocket.png"];
!
rocket.position = CGPointMake(50.0, 50.0);
!
[self addChild:rocket];
• Full Featured 2D particle system
• Configurable by attributes
• Xcode particle editor
• easy-to-use
• visual preview
SKEmitterNode!
Particles!
SKEmitterNode!
Particles!!
NSString *particlePath =
[[NSBundle mainBundle] pathForResource:@"flame" ofType:@“sks"];
!
SKEmitterNode *flames =
[NSKeyedUnarchiver unarchiveObjectWithFile:particlePath];
!
flames.particlePosition = CGPointMake(50.0, 50.0);
!
[self addChild:flames];
Demo
Textures & Atlases
• Fundamental Sprite Kit object
!
• Very Flexible
[SKTexture textureWithImageNamed:@"rocket.png"];
[SKTexture textureWithCGImage:myCGImageRef];
[SKTexture textureWithData:rgbaNSData size:CGSizeMake(100, 100)];
[SKTexture textureWithImage:myUIImage];
[SKTexture textureWithRect:CGRectMake(100, 100, 80, 80) inTexture:tex1];
SKTexture!
Sprite Kit bitmap data
• Many images combined into a single larger image
• Saves memory
• Improves drawing efficiency
rocket_red.png
rocket_green.png
rocket_flames.png
…
cloud.png
character_1.png
character_2.png
character_3.png
….
Texture Atlases!
Key to performance
• Load a SKTexture from a stand-alone file
• Load a SKTexture from a texture atlas
SKTexture *texture = [SKTexture textureWithImageNamed:@“rocket.png"];
SKTexture *texture = [SKTexture textureWithImageNamed:@“rocket.png"];
Texture Atlases!
Loading from a Texture Atlas
It’s the same! Sprite Kit manages atlases for you
Demo
Scenes & Transitions
• Root node of the scene graph
• Displayed by a SKView
• Inherits from SKEffectsNode
• Runs per-frame loop
-update:

-didEvaluateActions

-didSimulatePhysics
SKScene
Background Foreground
HUD
Hero
Score
Bg
Tree
Tree
SKScene!
Presents the content
SKScene!
Organization
• Level 1
!
• Level 2
!
• Level 3
!
• …
!
• Level N
• Main menu
• Game Options
• Game
• Game Over
Demo
Actions & Animations
• Very simple to use
• Single action class - SKAction
• One line creation
• Chain-able, reusable, readable
• Like a scripting language for Sprite Kit
• Actions directly affect the node it is run on
• Actions run immediately
• Removed on completion
[node runAction: [SKAction rotateByAngle:M_PI duration:1.0]];
Actions!
Basic Actions!
!
!
[SKAction rotateByAngle:M_PI duration:1.0];
!
[SKAction moveTo:aCGPoint duration:1.0];
!
[SKAction fadeAlphaTo:0.8 duration:1.0];
!
[SKAction scaleBy:2.0 duration:1.0];
!
[SKAction scaleXBy:1.5 y:0.5 duration:1.0];
Compound Actions!
Sequences!
[node runAction: [SKAction sequence:@[action1, action2, action3]]];
action1
1.0 sec
action2
2.0 sec
action3
0.5 sec
SKAction Sequence
3.5 sec
Compound Actions!
Groups!
[node runAction: [SKAction group:@[action1, action2, action3]]];
action1 1.0 sec
action2 2.0 sec
action3 0.5 sec
SKAction Group
2.0 sec
Specialty SKActions!
Animate!
[SKAction animateWithTextures:@[tex0, tex1, tex2, …] timePerFrame:0.1];
Specialty SKActions!
Follow path!
[SKAction followPath:myPath duration:2.5];
!
[SKAction followPath:myPath asOffset:YES orientToPath:NO duration:5.0];
• Zero duration, fires once
• Show the Game Over menu after character death animation
[SKAction runBlock:^{ doSomething(); }];
SKAction *fade = [SKAction fadeOutWithDuration:1.0];
SKAction *remove = [SKAction removeFromParent];
SKAction *showMenu = [SKAction runBlock:^{ [self showGameOverMenu]; }];
[heroSprite runAction: [SKAction sequence:@[fade, showMenu, remove]] ];
Specialty SKActions!
Run block
• moveByX:y:duration:
• moveTo:duration:
• moveToX:duration:
• moveToY:duration:
• rotateByAngle:duration:
• rotateToAngle:duration:
• scaleXTo:duration:
• scaleYTo:duration:
• speedBy:duration:
• speedTo:duration:
• scaleBy:duration:
• scaleXBy:y:duration:
• scaleTo:duration:
• scaleXTo:y:duration:
• sequence: group:
• setTexture: runBlock:
• runBlock:queue:
• removeFromParent
• performSelector:onTarget:
• resizeByWidth:height:duration:
• resizeToWidth:height:duration:
• resizeToWidth:duration:
• resizeToHeight:duration:
• repeatAction:count:
• repeatActionForever:
• fadeInWithDuration:
• fadeOutWithDuration:
• fadeAlphaBy:duration:
• fadeAlphaTo:duration:
• animateWithTextures:timePerFrame:
• animateWithTextures:timePerFrame:resize:
• playSoundFileNamed:waitForCompletion:
• colorizeWithColor:colorBlendFactor:
• colorizeWithColorBlendFactor:duration:
• followPath:duration:
• followPath:asOffset:orientToPath:
• waitForDuration:
• waitForDuration:withRange:
• runAction:onChildWithName:
• customActionWithDuration:actionBlock:
SKActions!
Huge list
Demo
physics
• Uses Box2D under the hood
• open source physics engine
• C++
• Objective-C API
• Fully integrated into Sprite Kit
Box2D
SpriteKit
Your code
Sprite Kit Physics
• Set the physics body of your Sprite
+ =
Physics Body
• Shape bodies
• Circle
• Rectangle
• Custom shaped
• Pixel (iOS8)
• Edge loop bodies
edge
Physics Bodies
• Restitution
• Density
• Friction
!
• Dynamic
• usesPreciseCollisionDetection
• allowsRotation
• affectedByGravity
• node
• …
Physics Properties!
Demo
Spritebuilder
Cocos2d
• SpriteBuilder Tool
• Scenes designer
• Animation timeline
• Less code to write
!
• Open Source
• Faster releases
!
• With Apportable also native Android
Features!
Demo
Thanks
• www.hufkens.net
• alain@hufkens.net
• @hufkens
!
• www.weetaps.com
• @weetaps
COntact

More Related Content

What's hot

Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)David Salz
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189Mahmoud Samir Fayed
 
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)   A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig) David Salz
 

What's hot (6)

Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185
 
The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181
 
XNA in a Day
XNA in a DayXNA in a Day
XNA in a Day
 
The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189
 
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)   A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
A simple and powerful property system for C++ (talk at GCDC 2008, Leipzig)
 

Viewers also liked

UI kit. Конструктор для больших проектов
UI kit. Конструктор для больших проектовUI kit. Конструктор для больших проектов
UI kit. Конструктор для больших проектовDenis Ilyin
 
SpriteKit (AnjLab Tech Talks)
SpriteKit (AnjLab Tech Talks)SpriteKit (AnjLab Tech Talks)
SpriteKit (AnjLab Tech Talks)AnjLab
 
Introduction to Sprite Kit
Introduction to Sprite KitIntroduction to Sprite Kit
Introduction to Sprite KitTai Lun Tseng
 
Sprite kitでの横スクロールジャンプ アクションゲーム開発
Sprite kitでの横スクロールジャンプ アクションゲーム開発Sprite kitでの横スクロールジャンプ アクションゲーム開発
Sprite kitでの横スクロールジャンプ アクションゲーム開発studioshin
 
November 2010 monthly fire rescue report final
November 2010 monthly fire rescue report finalNovember 2010 monthly fire rescue report final
November 2010 monthly fire rescue report finalcity of dania beach
 
201111 vujade shift-happened
201111 vujade shift-happened201111 vujade shift-happened
201111 vujade shift-happenedVujàdé
 
Edisi 31 Okt Aceh
Edisi 31 Okt AcehEdisi 31 Okt Aceh
Edisi 31 Okt Acehepaper
 
2014 Dania Beach Hurricane Preparedness Presentation
2014 Dania Beach Hurricane Preparedness Presentation2014 Dania Beach Hurricane Preparedness Presentation
2014 Dania Beach Hurricane Preparedness Presentationcity of dania beach
 
Nationaal petrol onderzoek 2014
Nationaal petrol onderzoek 2014Nationaal petrol onderzoek 2014
Nationaal petrol onderzoek 2014Rien De Koning
 
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...Carlos Borgia
 
1 q results 2012 - tpart-eng
1 q results   2012 - tpart-eng1 q results   2012 - tpart-eng
1 q results 2012 - tpart-engTIM RI
 
Epaper5 Maret Aceh
Epaper5 Maret AcehEpaper5 Maret Aceh
Epaper5 Maret Acehepaper
 
Back2 School Paola Powerpoint
Back2 School Paola PowerpointBack2 School Paola Powerpoint
Back2 School Paola Powerpointfran81503
 
June 2010 monthly fire rescue report
June 2010 monthly fire rescue reportJune 2010 monthly fire rescue report
June 2010 monthly fire rescue reportcity of dania beach
 
The power of social media uwo
The power of social media uwoThe power of social media uwo
The power of social media uwoThomas Clifford
 

Viewers also liked (20)

UI kit. Конструктор для больших проектов
UI kit. Конструктор для больших проектовUI kit. Конструктор для больших проектов
UI kit. Конструктор для больших проектов
 
SpriteKit (AnjLab Tech Talks)
SpriteKit (AnjLab Tech Talks)SpriteKit (AnjLab Tech Talks)
SpriteKit (AnjLab Tech Talks)
 
Sprite kit
Sprite kitSprite kit
Sprite kit
 
Introduction to Sprite Kit
Introduction to Sprite KitIntroduction to Sprite Kit
Introduction to Sprite Kit
 
Sprite kitでの横スクロールジャンプ アクションゲーム開発
Sprite kitでの横スクロールジャンプ アクションゲーム開発Sprite kitでの横スクロールジャンプ アクションゲーム開発
Sprite kitでの横スクロールジャンプ アクションゲーム開発
 
November 2010 monthly fire rescue report final
November 2010 monthly fire rescue report finalNovember 2010 monthly fire rescue report final
November 2010 monthly fire rescue report final
 
April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2
 
201111 vujade shift-happened
201111 vujade shift-happened201111 vujade shift-happened
201111 vujade shift-happened
 
Edisi 31 Okt Aceh
Edisi 31 Okt AcehEdisi 31 Okt Aceh
Edisi 31 Okt Aceh
 
2014 Dania Beach Hurricane Preparedness Presentation
2014 Dania Beach Hurricane Preparedness Presentation2014 Dania Beach Hurricane Preparedness Presentation
2014 Dania Beach Hurricane Preparedness Presentation
 
Nationaal petrol onderzoek 2014
Nationaal petrol onderzoek 2014Nationaal petrol onderzoek 2014
Nationaal petrol onderzoek 2014
 
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...
A. m.-no.-0088-norma-que-regula-los-contratos-individuales-de-trabajo-a-plazo...
 
Nonprofit energy alliance viii
Nonprofit energy alliance viiiNonprofit energy alliance viii
Nonprofit energy alliance viii
 
Fpb june 2010 3 year comps
Fpb   june 2010 3 year compsFpb   june 2010 3 year comps
Fpb june 2010 3 year comps
 
1 q results 2012 - tpart-eng
1 q results   2012 - tpart-eng1 q results   2012 - tpart-eng
1 q results 2012 - tpart-eng
 
Epaper5 Maret Aceh
Epaper5 Maret AcehEpaper5 Maret Aceh
Epaper5 Maret Aceh
 
Back2 School Paola Powerpoint
Back2 School Paola PowerpointBack2 School Paola Powerpoint
Back2 School Paola Powerpoint
 
June 2010 monthly fire rescue report
June 2010 monthly fire rescue reportJune 2010 monthly fire rescue report
June 2010 monthly fire rescue report
 
The power of social media uwo
The power of social media uwoThe power of social media uwo
The power of social media uwo
 
Airport Noise Presentation 2009
Airport Noise Presentation 2009Airport Noise Presentation 2009
Airport Noise Presentation 2009
 

Similar to iOS 2D Gamedev @ CocoaHeads

Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2dCodecamp Romania
 
Demo creating-physics-game.
Demo creating-physics-game.Demo creating-physics-game.
Demo creating-physics-game.sagaroceanic11
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kitBuşra Deniz, CSM
 
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchBringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchUnity Technologies
 
My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13Piotr Kowalski
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSides Delhi
 
cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介Jun-ichi Shinde
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたTaro Matsuzawa
 
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon[KJ-Code] Sprite Kit 설명 By Ji Sanghoon
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon상훈 지
 
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 Cocos2Dcreagamers
 
Cocos2dを使ったゲーム作成の事例
Cocos2dを使ったゲーム作成の事例Cocos2dを使ったゲーム作成の事例
Cocos2dを使ったゲーム作成の事例Yuichi Higuchi
 
飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDCShuichi Tsutsumi
 

Similar to iOS 2D Gamedev @ CocoaHeads (20)

Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2d
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
Demo creating-physics-game.
Demo creating-physics-game.Demo creating-physics-game.
Demo creating-physics-game.
 
Cocos2d programming
Cocos2d programmingCocos2d programming
Cocos2d programming
 
Cocos2d game programming 2
Cocos2d game programming 2Cocos2d game programming 2
Cocos2d game programming 2
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kit
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo SwitchBringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
Bringing Supernatural Thriller, "Oxenfree" to Nintendo Switch
 
My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13
 
BSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOSBSidesDelhi 2018: Headshot - Game Hacking on macOS
BSidesDelhi 2018: Headshot - Game Hacking on macOS
 
Cocos2d for beginners
Cocos2d for beginnersCocos2d for beginners
Cocos2d for beginners
 
cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介
 
Games on AppleWatch
Games on AppleWatchGames on AppleWatch
Games on AppleWatch
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
 
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon[KJ-Code] Sprite Kit 설명 By Ji Sanghoon
[KJ-Code] Sprite Kit 설명 By Ji Sanghoon
 
Soc research
Soc researchSoc research
Soc research
 
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
 
Cocos2dを使ったゲーム作成の事例
Cocos2dを使ったゲーム作成の事例Cocos2dを使ったゲーム作成の事例
Cocos2dを使ったゲーム作成の事例
 
飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC
 

Recently uploaded

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 

Recently uploaded (20)

Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 

iOS 2D Gamedev @ CocoaHeads

  • 1. iOS ~ 2d GameDev Alain Hufkens - @hufkens! CocoaHeadsBE - Hasselt - 2014-06-24
  • 3. • Geek Dad • 15y programming • Freelance • Wee Taps • CoderDojo Intro
  • 4.
  • 5. Agenda • Game Engines • SpriteKit • SpriteBuilder / Cocos2D • Q&A
  • 7. Cocos2d • 2008 • Simple 2D game engine • +10k games built with Cocos2D • Bought by Zynga • Spawned into Cocos2D-X • Development stopped for a while
  • 10. Sprite Kit • 2013 • 2D Game Framework • iOS7+ only • Provided by Apple (since iOS7) • Improved in iOS8 • Simple to prototype games
  • 12. Cocos2D V3 • 2014 • Cocos2D v3 • Spritebuilder • Supported by Apportable • 2D Game Development Suite • Cross Platform & Native
  • 19. SKNode! The base class! • Used for grouping in node tree @property SKNode *parent;
 @property SKNode *children; • Used for positioning itself and children @property CGPoint position; // relative to parent
 @property CGFloat zRotation; // radians
 @property CGFloat xScale, yScale; // scaling • Can control visibility @property CGFloat alpha;
 @property BOOL hidden; • Can run actions • Can be a physics body
  • 20. Sprite Kit Nodes! Node classes Class Description SKNode Parent class of all nodes SKScene Root of the scene graph SKSpriteNode! Renders a textured sprite SKEmitterNode Generates and renders particles SKLabelNode Renders a text string SKVideoNode Plays video content SKShapeNode Renders a shape SKEffectNode Applies a Core Image filter to its children SKCropNode Crops its children using a mask
  • 22. • Draws a Sprite • Can be a: • color • textured image • Has a explicit size SKSpriteNode SKSpriteNode
  • 23. SKSpriteNode! Simple creation SKSpriteNode *rocket = [SKSpriteNode spriteNodeWithImageNamed:@"rocket.png"]; ! rocket.position = CGPointMake(50.0, 50.0); ! [self addChild:rocket];
  • 24. • Full Featured 2D particle system • Configurable by attributes • Xcode particle editor • easy-to-use • visual preview SKEmitterNode! Particles!
  • 25. SKEmitterNode! Particles!! NSString *particlePath = [[NSBundle mainBundle] pathForResource:@"flame" ofType:@“sks"]; ! SKEmitterNode *flames = [NSKeyedUnarchiver unarchiveObjectWithFile:particlePath]; ! flames.particlePosition = CGPointMake(50.0, 50.0); ! [self addChild:flames];
  • 26. Demo
  • 28. • Fundamental Sprite Kit object ! • Very Flexible [SKTexture textureWithImageNamed:@"rocket.png"]; [SKTexture textureWithCGImage:myCGImageRef]; [SKTexture textureWithData:rgbaNSData size:CGSizeMake(100, 100)]; [SKTexture textureWithImage:myUIImage]; [SKTexture textureWithRect:CGRectMake(100, 100, 80, 80) inTexture:tex1]; SKTexture! Sprite Kit bitmap data
  • 29. • Many images combined into a single larger image • Saves memory • Improves drawing efficiency rocket_red.png rocket_green.png rocket_flames.png … cloud.png character_1.png character_2.png character_3.png …. Texture Atlases! Key to performance
  • 30. • Load a SKTexture from a stand-alone file • Load a SKTexture from a texture atlas SKTexture *texture = [SKTexture textureWithImageNamed:@“rocket.png"]; SKTexture *texture = [SKTexture textureWithImageNamed:@“rocket.png"]; Texture Atlases! Loading from a Texture Atlas It’s the same! Sprite Kit manages atlases for you
  • 31. Demo
  • 33. • Root node of the scene graph • Displayed by a SKView • Inherits from SKEffectsNode • Runs per-frame loop -update:
 -didEvaluateActions
 -didSimulatePhysics SKScene Background Foreground HUD Hero Score Bg Tree Tree SKScene! Presents the content
  • 34. SKScene! Organization • Level 1 ! • Level 2 ! • Level 3 ! • … ! • Level N • Main menu • Game Options • Game • Game Over
  • 35. Demo
  • 37. • Very simple to use • Single action class - SKAction • One line creation • Chain-able, reusable, readable • Like a scripting language for Sprite Kit • Actions directly affect the node it is run on • Actions run immediately • Removed on completion [node runAction: [SKAction rotateByAngle:M_PI duration:1.0]]; Actions!
  • 38. Basic Actions! ! ! [SKAction rotateByAngle:M_PI duration:1.0]; ! [SKAction moveTo:aCGPoint duration:1.0]; ! [SKAction fadeAlphaTo:0.8 duration:1.0]; ! [SKAction scaleBy:2.0 duration:1.0]; ! [SKAction scaleXBy:1.5 y:0.5 duration:1.0];
  • 39. Compound Actions! Sequences! [node runAction: [SKAction sequence:@[action1, action2, action3]]]; action1 1.0 sec action2 2.0 sec action3 0.5 sec SKAction Sequence 3.5 sec
  • 40. Compound Actions! Groups! [node runAction: [SKAction group:@[action1, action2, action3]]]; action1 1.0 sec action2 2.0 sec action3 0.5 sec SKAction Group 2.0 sec
  • 42. Specialty SKActions! Follow path! [SKAction followPath:myPath duration:2.5]; ! [SKAction followPath:myPath asOffset:YES orientToPath:NO duration:5.0];
  • 43. • Zero duration, fires once • Show the Game Over menu after character death animation [SKAction runBlock:^{ doSomething(); }]; SKAction *fade = [SKAction fadeOutWithDuration:1.0]; SKAction *remove = [SKAction removeFromParent]; SKAction *showMenu = [SKAction runBlock:^{ [self showGameOverMenu]; }]; [heroSprite runAction: [SKAction sequence:@[fade, showMenu, remove]] ]; Specialty SKActions! Run block
  • 44. • moveByX:y:duration: • moveTo:duration: • moveToX:duration: • moveToY:duration: • rotateByAngle:duration: • rotateToAngle:duration: • scaleXTo:duration: • scaleYTo:duration: • speedBy:duration: • speedTo:duration: • scaleBy:duration: • scaleXBy:y:duration: • scaleTo:duration: • scaleXTo:y:duration: • sequence: group: • setTexture: runBlock: • runBlock:queue: • removeFromParent • performSelector:onTarget: • resizeByWidth:height:duration: • resizeToWidth:height:duration: • resizeToWidth:duration: • resizeToHeight:duration: • repeatAction:count: • repeatActionForever: • fadeInWithDuration: • fadeOutWithDuration: • fadeAlphaBy:duration: • fadeAlphaTo:duration: • animateWithTextures:timePerFrame: • animateWithTextures:timePerFrame:resize: • playSoundFileNamed:waitForCompletion: • colorizeWithColor:colorBlendFactor: • colorizeWithColorBlendFactor:duration: • followPath:duration: • followPath:asOffset:orientToPath: • waitForDuration: • waitForDuration:withRange: • runAction:onChildWithName: • customActionWithDuration:actionBlock: SKActions! Huge list
  • 45. Demo
  • 47. • Uses Box2D under the hood • open source physics engine • C++ • Objective-C API • Fully integrated into Sprite Kit Box2D SpriteKit Your code Sprite Kit Physics
  • 48. • Set the physics body of your Sprite + = Physics Body
  • 49. • Shape bodies • Circle • Rectangle • Custom shaped • Pixel (iOS8) • Edge loop bodies edge Physics Bodies
  • 50. • Restitution • Density • Friction ! • Dynamic • usesPreciseCollisionDetection • allowsRotation • affectedByGravity • node • … Physics Properties!
  • 51. Demo
  • 53. • SpriteBuilder Tool • Scenes designer • Animation timeline • Less code to write ! • Open Source • Faster releases ! • With Apportable also native Android Features!
  • 54. Demo
  • 56. • www.hufkens.net • alain@hufkens.net • @hufkens ! • www.weetaps.com • @weetaps COntact