Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... ·...

Post on 04-Jul-2020

16 views 0 download

Transcript of Introduction to 2d Game Programming Using cocos2dhiddenelephantblog.dreamhosters.com/blog/wp... ·...

Introduction to 2d Game Programming Using cocos2d

Serban PorumbescuThursday, October 1, 2009

www.hiddenelephant.com

Thursday, October 1, 2009

Overview

• Why cocos2d?

• Beginner Hurdles

• cocos2d Basics

• cocos2d Specifics

• Samples and Tests

• Resources

Thursday, October 1, 2009

Why cocos2d?

• Well over 200 games shipped

• Great licensing

• Lots of features

• Extremely active community

• What’s your business?

Thursday, October 1, 2009

Beginner Hurdles

Thursday, October 1, 2009

Beginner Hurdles

• Objective-C and Memory

• Setting Up a cocos2d Project

• Running Samples and Tests

• Understanding Tests

Thursday, October 1, 2009

cocos2d Project Setup

• Super easy ... now

• sudo ./install_template.sh

Thursday, October 1, 2009

Thursday, October 1, 2009

Thursday, October 1, 2009

Thursday, October 1, 2009

Running Samples & Tests

• Wonderful source of examples that people seem to overlook

• Once noticed, folks have issues running

Thursday, October 1, 2009

Thursday, October 1, 2009

Running Samples & Tests

• Where are they and how do we run?

Thursday, October 1, 2009

Thursday, October 1, 2009

Thursday, October 1, 2009

Running Samples & Tests

• Make sure to set both the “Active Target” and the “Active Executable”

Thursday, October 1, 2009

Thursday, October 1, 2009

Thursday, October 1, 2009

Tests

• Not games

• Meant to exercise some specific functionality

• Useful for figuring stuff out

Thursday, October 1, 2009

Tests

• Structured very similarly

• Some base test class

• Instantiate new test by advancing through NSStrings using NSClassFromString

Thursday, October 1, 2009

Tests

• Let’s look at AtlasSpriteTest and EaseActionsTest

Thursday, October 1, 2009

cocos2d Basics

Thursday, October 1, 2009

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

Scenes

• Screens in your game

• Can almost think of them as separate apps

Thursday, October 1, 2009

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

Sprites

Thursday, October 1, 2009

Director

• Manages moving between Scenes

• Pausing and running Scenes

• Sets up OpenGL ES

• Layer asks Director to move on

Thursday, October 1, 2009

Thursday, October 1, 2009

cocos2d Specifics

Thursday, October 1, 2009

Thursday, October 1, 2009

Important Classes• CocosNode

• Scene

• Layer

• Director

• AtlasSprite

• AtlasSpriteManager

Thursday, October 1, 2009

CocosNode

Thursday, October 1, 2009

CocosNode

• Lots of properties

• position, scale, camera, OpenGL z position, children

• Most objects in cocos2d inherit from CocosNode

Thursday, October 1, 2009

Scene

Thursday, October 1, 2009

Layer

Thursday, October 1, 2009

Director(s)

Thursday, October 1, 2009

AtlasSprite

Thursday, October 1, 2009

AtlasSpriteManager

Thursday, October 1, 2009

Sprite vs. AtlasSprite

Thursday, October 1, 2009

Sprites

Thursday, October 1, 2009

AtlasSprite

Thursday, October 1, 2009

Sprite vs. AtlasSprite

• In general, don’t use Sprites

• AtlasSprites way faster

• It’s all about the OpenGL ES

Thursday, October 1, 2009

Samples and Tests

Thursday, October 1, 2009

Resources

http://www.cocos2d-iphone.org/

Thursday, October 1, 2009

Resources

Wiki: http://www.cocos2d-iphone.org/wiki/doku.php/

Thursday, October 1, 2009

Resources

Forums: http://www.cocos2d-iphone.org/forum/

Thursday, October 1, 2009

iPhoneGameJam.com

Thursday, October 1, 2009

Thanks!

Thursday, October 1, 2009