introduction to 2d game programming using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... ·...
TRANSCRIPT
![Page 1: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/1.jpg)
Introduction to 2d Game Programming Using cocos2d
Serban PorumbescuThursday, October 1, 2009
![Page 2: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/2.jpg)
www.hiddenelephant.com
Thursday, October 1, 2009
![Page 3: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/3.jpg)
Overview
• Why cocos2d?
• Beginner Hurdles
• cocos2d Basics
• cocos2d Specifics
• Samples and Tests
• Resources
Thursday, October 1, 2009
![Page 4: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/4.jpg)
Why cocos2d?
• Well over 200 games shipped
• Great licensing
• Lots of features
• Extremely active community
• What’s your business?
Thursday, October 1, 2009
![Page 5: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/5.jpg)
Beginner Hurdles
Thursday, October 1, 2009
![Page 6: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/6.jpg)
Beginner Hurdles
• Objective-C and Memory
• Setting Up a cocos2d Project
• Running Samples and Tests
• Understanding Tests
Thursday, October 1, 2009
![Page 7: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/7.jpg)
Learn Objective-C
Read: “Learning Objective-C: A Primer”
Thursday, October 1, 2009
![Page 8: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/8.jpg)
Learn Memory Management
Read: “Memory Management Programming Guide for Cocoa”
Thursday, October 1, 2009
![Page 9: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/9.jpg)
cocos2d Project Setup
• Super easy ... now
• sudo ./install_template.sh
Thursday, October 1, 2009
![Page 10: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/10.jpg)
Thursday, October 1, 2009
![Page 11: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/11.jpg)
Thursday, October 1, 2009
![Page 12: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/12.jpg)
Thursday, October 1, 2009
![Page 13: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/13.jpg)
Running Samples & Tests
• Wonderful source of examples that people seem to overlook
• Once noticed, folks have issues running
Thursday, October 1, 2009
![Page 14: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/14.jpg)
Thursday, October 1, 2009
![Page 15: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/15.jpg)
Running Samples & Tests
• Where are they and how do we run?
Thursday, October 1, 2009
![Page 16: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/16.jpg)
Thursday, October 1, 2009
![Page 17: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/17.jpg)
Thursday, October 1, 2009
![Page 18: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/18.jpg)
Running Samples & Tests
• Make sure to set both the “Active Target” and the “Active Executable”
Thursday, October 1, 2009
![Page 19: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/19.jpg)
Thursday, October 1, 2009
![Page 20: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/20.jpg)
Thursday, October 1, 2009
![Page 21: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/21.jpg)
Tests
• Not games
• Meant to exercise some specific functionality
• Useful for figuring stuff out
Thursday, October 1, 2009
![Page 22: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/22.jpg)
Tests
• Structured very similarly
• Some base test class
• Instantiate new test by advancing through NSStrings using NSClassFromString
Thursday, October 1, 2009
![Page 23: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/23.jpg)
Tests
• Let’s look at AtlasSpriteTest and EaseActionsTest
Thursday, October 1, 2009
![Page 24: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/24.jpg)
cocos2d Basics
Thursday, October 1, 2009
![Page 25: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/25.jpg)
cocos2d Basics
• Game has Scenes
• Each Scene has some number of Layers
• Layers capture user interaction and contain sprites
• Director manages the scenes
Thursday, October 1, 2009
![Page 26: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/26.jpg)
Scenes
• Screens in your game
• Can almost think of them as separate apps
Thursday, October 1, 2009
![Page 27: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/27.jpg)
Layers
• Take up the entire screen
• Setup to handle touch and accelerometer
• Can contain other layers and sprites (and other stuff)
Thursday, October 1, 2009
![Page 28: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/28.jpg)
Sprites
Thursday, October 1, 2009
![Page 29: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/29.jpg)
Director
• Manages moving between Scenes
• Pausing and running Scenes
• Sets up OpenGL ES
• Layer asks Director to move on
Thursday, October 1, 2009
![Page 30: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/30.jpg)
Thursday, October 1, 2009
![Page 31: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/31.jpg)
cocos2d Specifics
Thursday, October 1, 2009
![Page 32: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/32.jpg)
Thursday, October 1, 2009
![Page 33: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/33.jpg)
Important Classes• CocosNode
• Scene
• Layer
• Director
• AtlasSprite
• AtlasSpriteManager
Thursday, October 1, 2009
![Page 34: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/34.jpg)
CocosNode
Thursday, October 1, 2009
![Page 35: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/35.jpg)
CocosNode
• Lots of properties
• position, scale, camera, OpenGL z position, children
• Most objects in cocos2d inherit from CocosNode
Thursday, October 1, 2009
![Page 36: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/36.jpg)
Scene
Thursday, October 1, 2009
![Page 37: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/37.jpg)
Layer
Thursday, October 1, 2009
![Page 38: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/38.jpg)
Director(s)
Thursday, October 1, 2009
![Page 39: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/39.jpg)
AtlasSprite
Thursday, October 1, 2009
![Page 40: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/40.jpg)
AtlasSpriteManager
Thursday, October 1, 2009
![Page 41: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/41.jpg)
Sprite vs. AtlasSprite
Thursday, October 1, 2009
![Page 42: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/42.jpg)
Sprites
Thursday, October 1, 2009
![Page 43: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/43.jpg)
AtlasSprite
Thursday, October 1, 2009
![Page 44: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/44.jpg)
Sprite vs. AtlasSprite
• In general, don’t use Sprites
• AtlasSprites way faster
• It’s all about the OpenGL ES
Thursday, October 1, 2009
![Page 45: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/45.jpg)
Samples and Tests
Thursday, October 1, 2009
![Page 46: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/46.jpg)
Resources
http://www.cocos2d-iphone.org/
Thursday, October 1, 2009
![Page 47: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/47.jpg)
Resources
Wiki: http://www.cocos2d-iphone.org/wiki/doku.php/
Thursday, October 1, 2009
![Page 48: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/48.jpg)
Resources
Forums: http://www.cocos2d-iphone.org/forum/
Thursday, October 1, 2009
![Page 49: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/49.jpg)
iPhoneGameJam.com
Thursday, October 1, 2009
![Page 50: Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... · Introduction to 2d Game Programming Using cocos2d Serban Porumbescu Thursday, October](https://reader034.vdocuments.mx/reader034/viewer/2022052613/5f1ac84649ffe614740966f7/html5/thumbnails/50.jpg)
Thanks!
Thursday, October 1, 2009