Index

imagesA

acceleratePlayerWithX method, 456

acceleration.x parameter, 91

Achievements, Game Kit programming

authenticateWithCompletionHandler, 390

GameKitHelper class, 387

GameKitHelper showAchievements method, 387

getAchievementByID method, 391

loadAchievements method, 390391

NSMutableDictionary, 391

onScoresReceived method, 387

percentComplete property, 389

PlayedForTenSeconds achievement, 389

progress determination, 389

progress reporting, 389

resetAchievements method, 391

view, 388

addRandomSpriteAt method, 311

addSomeCocoaTouch method, 406, 408, 414, 419, 422

addSomeJoinedBodies method, 311

addSpriteFramesWithFile, 164

addSubview method, 409

AdMob, 493

AdWhirl, 493

afconvert command, 108

alignItemsVerticallyWithPadding, 68

anchorPoint property, 65, 66

animationWithFile helper method, 156

animationWithFile method, 154, 165, 166

animationWithFrame method, 166

AppDelegate class

animation interval, 26

applicationDidFinishLaunching method, 25

dealloc method, 25

device orientation, 25

FPS display, 27

UIApplicationDelegate protocol, 25

AppDelegate's dealloc method, 25

Apple's UIResponder class, 61

Application programming interface (API), 401

applicationDidFinishLaunching method, 386, 412, 415, 424

ARMv6, 423

authenticateLocalPlayer method, 377

authenticateWithCompletionHandler method, 377

imagesB

BATAK Duel source code, 475476

Block objects, 377

authenticateWithCompletionHandler method, 380

callback functions, 378

C-language extension, 378

lastError variable, 379

multithreaded and asynchronous programming tasks, 378

NSError pointer, 379

Box2D

addNewSpriteAt method, 305306

allowBodiesToSleep variable, 302

b2BodyDef type property, 306

b2PolygonShape set, 306

b2Vec2 struct type, 302

b2World, 301

Box2D API reference, 300

CCSpriteBatchNode, 306

vs. Chipmunk, 299

cocos2d Box2D application template, 300

collision detection

b2ContactListener class, 308

BeginContact method, 308309

Box2D API reference, 309

ContactListener class's interface, 308

dealloc method, 309310

EndContact method, 308309

HelloWorldScene, 309

converting points, 304

deallocate message, 301

Donate button, 301

GDC, 300

Hello World Interface, 301

joint venture, 310311

movement restriction

b2BodyDef, 302

b2PolygonShape variable, 303

CreateBody method, 302

PTM_RATIO 32, 304

PTM_RATIO constant, 303

screen area, four sides, 302

screenBoxShape variable, 303

SetAsEdge method, 303

Objective-C class, 301

orthogonal tileset, 305

PhysicsBox2D01 project, 305

SetAsBox method, 306

sleeping bodies, 302

sprites connection, 306, 307

update method, 305

Box2D.h header file, 442

bringSubviewToFront message, 414

Bullets

bulletSpriteBatch method, 149

CCMoveTo and CCMoveBy actions, 148

memory allocations, 150

position, 148

Ship class, 148150

ship shooting, 147

shoot method, 151152

tag, 147

z-order, 147

bulletSpriteBatch accessor, 150

imagesC

CADisplayLink class, 52

CCActionEase class, 7274

CCActionInstant class hierarchy, 76

CCActionInstant subclass, 69

CCActionInterval actions, 70

CCActionInterval class hierarchy, 70, 71

CCActionInterval subclass, 69

CCAnimationCache, 155

CCAnimation class, 154

CCAnimationHelper class, 165

CCCallFunc actions, 77, 78

CCDirector class, 434, 450

CCDirector runWithScene method, 447

CCDirector setDeviceOrientation method, 425

CCFileUtils class, 411

CCGridAction class, 74

CCGrid3DAction class hierarchy, 75

CCGrid3DAction subclass, 74

CCInstantAction class hierarchy, 76

CCKeyboardEventDelegate protocol, 62

CCLabelBMFont class, 107, 403

CCLabelTTF class, 28

CCLabelTTF node, 41, 44

CCLayer class, 27, 41, 43, 51, 449

CCLayer subclass, 83

CCLayerColor class, 460

CCMenu, 403

CCMenuItemSprite, 68

CCMenuItemToggle, 68

CCMotionStreak class, 139

CCMouseEventDelegate protocol messages, 63

CCMoveAction, 396

CCNode class, 27, 43, 51, 83

CCNode-based class, 405

CCPageTurn3D action, 76

CCParallaxNode class

CCMoveBy actions, 137

CGPoint, 137

illusion of depth, 136

parallaxing, 135136

parallaxRatio, 137

ScenesAndLayers08 project, 136

CCParticleSystem, 218219

emitter duration, 225

emitter modes

emitterMode property, 226

gravity, 226, 227

radius, 227, 228

initWithTotalParticles method, 225

particle blend mode, 231

particle color, 230

particle direction, 229

particle lifetime, 229

particle position, 228

particle size, 229

particle texture, 232, 233

Point/Quad

ARCH_OPTIMAL_PARTICLE_SYSTEM, 222

ARMv7 CPU architecture, 222

CCParticleSystemPoint, 222

CCParticleSystemQuad, 222

optimal particle system class, 222

properties, 223224

totalParticles property, 225

variance properties, 224

ccpDistance method, 102

CCProgressTimer class

CCProgressTimer node, 134

CCProgressTimerType, 135

scheduleUpdate, 135

update method implementation, 135

UserInterfaceLayer class, 134

CCRepeatForever action, 72

CCRepeatForever sequences, 78

CCRibbon class, 138139

CCScene class, 41, 43, 51, 405, 449

CCScene node, 27

CCSequence action, 72

CCSpriteFrameCache's method, 164

CCSprite node, 41

CCStandardTouchDelegate protocol, 131

CCTargetedTouchDelegate protocol, 131

CCTextureCache addImage method, 242

CCTexture2D texture, 66

CCTiledGrid3DAction class hierarchy, 74, 75

CCTintTo actions, 77

ccTouchesBegan method, 33, 62

ccTouchesEnded method, 60

CCTransitionFade, 58

CCTransitionFadeTR, 58

CCTransitionJumpZoom, 58

CCTransitionMoveInL, 58

CCTransitionPageTurn, 58

CCTransitionRadialCCW, 58

CCTransitionRotoZoom, 58

CCTransitionScene, 115, 405

CCTransitionSceneOriented, 58

CCTransitionShrinkGrow class, 54, 59

CCTransitionSlideInL, 59

CCTransitionSplitCols, 59

CCTransitionTurnOffTiles, 59

CGGeometry methods, 125

CGPoint, 91

CGPointExtension files, 102

CGRectContainsPoint, 133

Chillingo's Crystal, 490

Chipmunk SpaceManager, 299

C++ interface, 299

Cocoa Touch

API, 401

cocos2d

engine starting, 432434

engine stopping and restarting, 434435

Game Center, 402

graphical frameworks, 402

hybrid app's user interface, 430432

iAd, 402

Interface Builder, 402

limitations, 403

MVC pattern, 404

OpenGL ES, 402405

scenes changing, 436437

View-based Application (see View-based Application)

Game Kit/Web Kit, 402

GUIs, 402

Cocos2D Central, 2

Cocos2d game engine, 467

accelerometer controls, 11

Android devices, 7

API documentation, 9

App Store, 1

BATAK Duel source code, 475476

bitmap font tools, 477

building blocks, 12

China Unicom, 7

Cocos2D Central, 2, 469

Cocos2D Podcast, 476477

cocos2d-iphone project

community, 7

Farmville, 6

OpenGL ES 2.0, 6

Sapus Media, 6

Zynga, 6

community, 467

C++ version, 7

essentials, 11

Game Center, 13

game-programming API, 1

games making business

engaging players (see Engaging players)

finding freelancers, 484

free art and audio, 484

marketing (see Marketing)

trade tools, 485

working with publishers, 482483

"Hello World" project, 11

help, 468

home page, 468

iOS

app developers, 10

CCSprite class, 5

Cocoa Touch user interface elements, 5

cocos2d developers, 11

community, 5

2D, 4

free cost, 3

Objective-C, 3, 4

OpenGL ES code, 45

open source, 3

ParticleDesigner tools, 10

physics engines, 4

programming, 5

TexturePacker tools, 10

iPhone RPG Game Kit, 471, 474

isometric tilemaps, 12

iUridium source code, 474475

Kobold2D, 13

Line-Drawing Game Starterkit, 472

Objective-C code, 7

parallax scrolling shooter game, 12

particle editing tools, 477

particle effects, 12

physics editing tools, 477

physics engines, 12

Pinball game, 13

Platformer Game Kit, 472473

ports, 7, 8

prerequisites

Objective-C, 89

programming experience, 8

reference apps

Abstract War 2.0, 481

Bloomies, 478, 479

Elements, 478

Farmville, 480

Fuji Leaves, 481

Melvin Says There's Monsters, 480

StickWars, 479

Super Turbo Action Pig, 480

Trainyard, 481

ZombieSmash, 479, 480

scene editing tools, 477

second edition, 23

shoot 'em up, 12

source code, 13, 470471

Space Game Starterkit, 473474

sprites in-depth, 12

Stack Exchange network, 469

texture atlas tools, 478

tilemap editing tools, 478

tilemaps, 12

tutorials and FAQs, 470

UIKit views, 13

World Wide Web, 9

www.learn-cocos2d.com, 467

Cocos2d games, 15

application creation

HelloWorld project, 19, 20

project running in iOS Simulator, 20, 21

Xcode project templates, 19

certificates and provisioning profiles, 1617

changing the world

CCLabelTTF object, 3334

CCLayer class, 33

getChildByTag, 3334

label object access, 3233

NSAssert method, 3334

self.isTouchEnabled, 33

Cocos2d Central download, 17

Debug and Release, 39

HelloWorld application

AppDelegate class (seeAppDelegate class)

files location, 22

HelloWorldLayer class, 2729

Main.m, 2324

precompiled prefix header, 24

resources, 23

iOS devices

hardware differences, 34, 35

iPhone 4, 35

iPod touch models, 34

second-generation devices, 35

iOS SDK, 17

iOS simulator, 37, 39

memory management

addChild, 31

autorelease message, 2930

CCArray, 31

CCNode* myNode variable, 31

CCNode object, 3031

cocos2d objects, 31

NSMutableArray, 31

release message, 30

memory usage, 3637

register as iOS developer, 16

system requirements, 1516

Xcode project templates installation, 18

Cocos2D Podcast, 476477

cocos2dVersion method, 368

Cocos3d

addition, 464465

AppDelegate class

augmented reality, 458, 459

CC3Layer class, 460

CCNodeController class, 458, 461

CC3World class, 460

HelloWorldLayer, 461

implementation, 459460

isOverlayingDeviceCamera property, 459

node controller, 461

real-time camera background, 458

RootViewController class, 458

sandwiched 3D model, 461

useNodeController variable, 459

CC3Layer class, 462

CC3Light node, 463

CC3MeshNode, 463

CC3Node class, 462

CC3World class, 462

COLLADA format, 464

createGLBuffers method, 464

Hello-Cocos3D template project, 457

initializeWorld method, 462463

PowerVR POD files, 464

releaseRedundantData, 464

CocosDenshion audio functionality, 108

Collision_type property, 318

contentSize property, 98

convertEventToGL method

, 64

cpArbiterGetShapes method, 318

cpSpaceAddCollisionHandler method, 318

cpSpaceHashEach method, 316

createPositionPacket method, 399

createScorePacket method, 399

imagesD

David Gervais's tileset, 273, 277, 278

Doodle Drop GameLayer class, 455

DoodleDrop game, 81

accelerometer input, 91

collision detection, 101102

final version, 81

first test run, 91

iPad porting

App Store, 110

iPhone and iPad versions, 110

Universal apps, 109

with Xcode 3, 110111

with Xcode 4, 111112

labels and bitmap fonts

CCLabelBMFont, 104

CCLabelTTF class, 103

currentTime, 103

Glyph Designer, 105107

score label, 103104

totalTime, 103

obstacles addition

CCArray class, 97

CCCallFuncN action, 100, 101

CCMoveTo action, 100

dealloc method, 96

EXC_BAD_ACCESS error, 96

GameScene init method, 95

GameScene.h file, 95

initSpiders method, 9596

logging statement, 100

node's position, 99

NSAssert, 101

numSpidersMoved, 95

resetSpiders method, 99

resetting spider position, 101

runSpiderMoveSequence method, 100

spider sprite positions resetting, 98

spider.png, 95

spiderDidDrop method, 100

spiderMoveDuration, 95, 100

spidersUpdate method, 99

tempSpider CCSprite, 96

player sprite

accelerometer input, 89

alien.png, 87, 89

CCSprite* member, 89

contentSize property, 90

GameScene class, 88

image height, 90

image sizes, 90

JPEG files, 88

keeping a weak reference, 89

positioning, 90

resource files addition, 87, 88

player velocity

acceleration and deceleration, 92

accelerometer code, 92, 93

accelerometer control, 95

actions, 92

CGPoint variable, 92

contentSize width, 94

current velocity, 9394

design parameters, 93

filtering, 95

GameScene init method, 93

imageWidthHalved, 94

–(void) update:(ccTime)delta method, 93

playing audio, 107108

project setup

autorotation, 87

CCNode-derived classes, 83, 84

Classes and Resources groups, 82, 83

cocos2d Application template, 82

DoodleDropAppDelegate.m file, 86, 87

GameScene class, 85

GameScene.h, 8486

GameScene.m, 8486

HelloWorldScene class, 83, 86

save file dialog, 83, 85

dummyView, 419

imagesE

EAGLView, 414, 415, 431, 435

Electrotanks's Electroserver, 491

enableRetinaDisplay, 144

Engaging players

earning revenue

ads and analytics, 492493

In App Purchases, 493

iCloud, 492

iOS platform, 489

push notification providers, 491

social networks, 489490

socket server technology, multiplayer games, 490491

Entity class hierarchy

component classes, 209211

EnemyCache class

CCArray, 208

enemies initialization, 206207

enemiesOfType CCArray, 207

init method, 205206

interface, 205

spawnEnemyOfType method, 208

spawning Enemies, 207208

unspectacular header file, 205

update method, 208

EnemyEntity class

dealloc method, 204

EnemyType_MAX, 202

EnemyTypes enum, 202

initSpawnFrequency method, 203204

initWithType method, 202203

interface, 201

numberWithInt initializer, 204

spawn method, 204205

StandardMoveComponent, 203

static spawnFrequency CCArray, 204

switch statement, 203

visible status, 205

Entity, definition, 201

isOutsideScreenArea function, 201

screen rectangle run, 201

setPosition code, 201

ShipEntity, 201

Entry-level tutorials, 470

EPacketTypes type field, 397

Essentials Xcode project, 41

actions

CCAction class hierarchy, 69

CCFollow action, 69

CCRepeatForever action, 69

CCSpeed action, 70

ease actions, 7274

grid actions, 7476

instant actions, 7677

interval, 7071

sequences, 72

CCDirector class

iOS deployment target setting, 53

kCCDirectorTypeDisplayLink, 52

kCCDirectorTypeMainLoop, 52

kCCDirectorTypeNSTimer, 52

kCCDirectorTypeThreadMainLoop, 52

NSTimer object, 52

responsibilities, 51

sharedDirector method, 51

singleton, 51

types, 52

CCLabelTTF class, 66

CCLayer class

accelerometer events, 62

adding scene, 59

backgroundLayer, 59

keyboard events, 62

mouse events, 63

touch events, 6062

userInterfaceLayer, 59

CCNode class

abstract class, 46

actions, 47

child nodes, 46

hierarchy, 4445

scheduled messages (see Scheduled messages)

tag parameter, 46

z parameter, 46

CCScene class

applicationDidFinishLaunching method, 54

CCLayer object, 54

CCSceneTransition, 53

CCTransitionShrinkGrow class, 54

pushScene method, 53

replaceScene method, 53, 54

runWithScene method, 53, 54

CCSprite class

anchor points, 65

CCTexture2D texture, 64

texture dimensions, 65

CCTransitionScene subclass

hierarchy, 57

popScene, 58

replaceScene and pushScene, 58

transitions, 5859

cocos2d scene graph

background layer, 42

CCNode class, 41

CCScene and CCLayer, 42

child node position, 44

exploded view, 42

game objects layer, 42

node hierarchy, 43, 44

shoot 'em up game, 41, 42

virtual joypad layer, 42

Cocos2d test cases, 80

menus

CCMenu class, 67

CCMenu node, 68, 69

CCMenuItem class hierarchy, 67

CCMenuItemFont, 68

CCMenuItemImage, 68

CCMenuItemLabel class, 68

menuItem1Touched method, 68

MenuScene class, 6768

pushing and popping scenes, 5556

scenes and memory, 5455

Singletons

MyManager class, 78

static autorelease initializer, 78

tight coupling, 79

Exit Games, 491

imagesF

FadeIn/FadeOut actions, 129

Farmville, 6

fastRemoveObject method, 97

fastRemoveObjectAtIndex method, 97

floatValue method, 257

Flurry Analytics, 493

forEachShape method, 316

frameCount parameter, 155

fullPathFromRelativePath, 411

imagesG

Game building blocks, 115

CCNode class

CCMotionStreak class, 139140

CCParallaxNode class, 135137

CCProgressTimer class, 134135

CCRibbon class, 138139

game objects, CCSprite

composition (see Game object composiion)

subclassing, 128129

multiple layers

CCLayerColor, 128

ccTouchBegan, 125

ccTouchEnded, 126

ccTouchMoved event, 126

CGRectContainsPoint, 125

dealloc method, 122

GameLayer class, 123124

GameLayer rotated and zoomed out, 126

getChildByTag method, 123

isTouchForMe method, 124, 125

LayerTagGameLayer, 122

levels implementation, 126127

MultiLayerScene class, 121122

multiLayerSceneInstance variable, 122

registerWithTouchDispatcher, 124

ScenesAndLayers04 project, 121

semi-singleton object, 122

sharedLayer method, 122

TargetedTouchDelegate, 124

TargetedTouchHandlers, 123

touch events, 125126

UserInterfaceLayer class, 123124

multiple scenes

adding more classes, 115

CCDirector replaceScene method, 115

CCScene class, 118

debugging, 117

FirstScene dealloc method, 117

FirstScene onExit method, 117

init/dealloc method, 116

initWithTargetScene method, 120

LoadingScene class, 118120

LoadingScene.h file, 118

myArray, 118

NSMutableArray instance variable, 118

onEnter method, 117

onExit method, 115, 118

OtherScene CCLayer's init method, 117

ScenesAndLayers02 project, 116

ScenesAndLayers03 project, 118

sceneWithTargetScene method, 120

scheduleUpdate, 119, 120

switch statement, 120

TargetScenes enum, 120

Game Center, 365

Cocos2d Xcode project

Build Phases tab, 370

Bundle ID, 368, 369

Bundle identifier key, 368, 369

creation, 367

GameKit.framework addtion, 370, 371

GameKit.h header file, 371

Game Kit requirement, 369, 370

Info.plist UIRequiredDeviceCapabilities list, 369

prefix header, 372

Prefix.pch file, 371

Property List editor, 368

Tilemap_Prefix.pch file, 371

Game Kit API, 366

GameKitHelper class, 365

Game Kit programming

achievements (see Achievements, Game Kit programming)

availability checking, 374

block objects (see Block objects)

GameKitHelper delegate, 373374

leaderboards (see Leaderboards)

local player authentication (see Local player authentication)

local player's friend list, 380381

matchmaking (see Matchmaking)

sending and receiving data, 396399

iOS 3.0, 366

iOS 4.1, 365, 366

iTunes Connect, 366

leaderboards and achievements, 365367

player accounts and friend list, 365

setup procedure, 372

Game Developers Conference (GDC), 300

GameKitHelper init method, 375, 377

Game objects composition

CCNode class, 129

CCStandardTouchDelegate protocol, 131

CCTargetedTouchDelegate protocol, 131

ccTouchBegan method, 133

CCTouchDispatcher class, 131

changed Spider class, 132133

initWithParentNode method, 130

moveAway method, 133

NSObject class, 129

parentNode parameter, 130

Spider class implementation, 130131

Spider class interface, 130

spiderSprite class, 130

GameScene class, 103, 150

getAchievementByID method, 391

getChildByTag method, 46

getLocalPlayerFriends method, 381

GKAchievementViewControllerDelegate protocol, 387

GKLeaderboardPlayerScopeGlobal, 384

GKLeaderboardPlayerScoreFriendsOnly, 384

GKLeaderboardViewControllerDelegate protocol, 385

GKLocalPlayer class, 381

GKMatchmakerViewControllerDelegate protocol, 393

GKMatchSendDataReliable data mode, 396

GKPlayer class, 381382

glClearColor, 415

GLESDebugDraw class, 343

Global identifiers (GIDs) concept, 256

glView, 414

glView.superview, 414

Glyph Designer, 2

Graphical user interfaces (GUIs), 402

imagesH

Handholding approach, 470

Hello Kobold2D template project

AppDelegate class, 447

config.lua file, 448

config.lua script file, 448, 449

files, 445, 446

FirstSceneClassName, 447, 449

iSimulate, 454455

KKAppDelegate class, 447

KKMain method, 446

KKStart-upConfig class, 449

Lua table, 448

main.m file, 446

NSApplicationDelegate class, 447

Objective-C method, 448

RootViewController class, 447

scene and layer

config.lua file, 450451

cross-platform development, 453

custom config.lua settings, 451

director properties, 453

FirstSceneClassName, 450

HelloWorldLayer class, 450

HelloWorldSettings, 451

implementation file, 452453

KKConfig, 451, 452

preprocessor macros, 453

Wax library, 448

XML files, 448

HelloWorldLayer class, 433, 437

Hiero Bitmap Font tool, 2

Hiero tool, 104

High-definition (HD) graphics, 142

hitTest method, 416, 418

hitTestNodeChildren method, 417

Human Interface Guidelines (HIG), 423

imagesI, J

iAd, 454, 493

Indiepinion, 470

init method, 29

initializationComplete, 447

initWithContentsOfFile, 411

initWithParentNode method, 130

initWithSpriteFrameName method, 164

initWithTargetScene method, 120

Interface Builder, 402, 403, 408

Attributes Inspector, 422

CocosWithCocoa05 project, 419

initWithNibName, 422

Landscape mode, 422

MyView class, 422

MyView.xib file, 421, 422

nib files, 420

orientation, 422

sendSubviewToBack message, 422

UIViewController subclass, 420, 422

Xcode 4, 419, 421

iOS 5, 2

iPad Simulator, 111

isGameCenterAvailable, 376

iSimulate library, 455

isKindOfClass method, 101

Isometric tilemap games, 269

Cocos2d

addChild method, 280

cc_vertexz properties, 279

CCDirector, 279

depthFormat parameter, 280

EAGLView, 279

GL_DEPTH_COMPONENT24_OES, 280

ground floor, 280

ground layer, 279

OpenGL depth buffer, 279

setProjection initialization, 280

tilemap loading, 278279

UIWindow, 280

vertexZ property, 280

zOrder property, 280

3D-rendering performance, 269

impassable map border area, 285, 286

isometric graphics

dg_iso32.png, 272, 273

door arch, 272

ground floor pattern, 271

isometric projection, 270

orthogonal image, isometric diamond shape, 270

orthogonal tileset into isometric tileset, 271

perspective projection, 270

isometric tile location

CGPoint tilePosDiv creation, 282

coordinate system, 281

halfMapWidth coordinate, 283

inverseTileY variable, 282

Objective-C MIN and MAX macros, 283

tilePosFromLocation method, 282

isometric.tmx file, 284

movable player character

anchorPoint, 288

blocks_movement tile property, 293

ccTouchesBegan method, 291

centerTileMapOnTileCoord method, 292

CGRect variables, 290

collisions layer, 293

currentMoveDirection variable, 291

EMoveDirection enum, 290

ensureTilePosIsWithinBounds method, 292

isTilePosBlocked method, 293294

move behind tiles, 288289

MoveDirectionNone signaling, 290

movement directions, 290

moveOffsets array, 291

player class implementation, 287

player class interface, 287

TileMapLayer class interface, 290

TileMapLayer class's init method, 287

tilePosFromLocation, 292

touch location, 291292

update method, 294

ninja character, 269

nonplayer characters, 295

playable area variables, 286

resize map, 284, 285

scrolling, 283284

tiled map editor (see Tiled map editor)

TileMapLayer class, 286

tilePosFromLocation method, 284

isTouchEnabled property, 60

iTunes Connect, 365

iUridium source code, 474475

imagesK

kEAGLColorFormatRGB565 pixel format, 415

kEAGLColorFormatRGBA8 pixel format, 415

KKAcceleration class, 456

KK_PLATFORM_IOS macro, 453

KK_PLATFORM_IOS_DEVICE macro, 453

KK_PLATFORM_IOS_SIMULATOR macro, 453

KK_PLATFORM_MAC macro, 453

Kobold2D, 2, 3, 13, 439, 473

advantages

cocos2d-iphone, 440

cross-platform, 442

easy to upgrade, 440

free, 440

graphical user interface, 440

Lib Service, 441442

Linux distribution, 440

ready to use, 440

cocos3d (see Cocos3d)

Core Motion framework, 439

Hello Kobold2D template project, 444

libraries, 439

Mac Doodle Drop with KKInput

acceleration values, 455

accelerometer:didAccelerate event method, 455

anyTouchEnded method, 456

filtering factor, 455

input.acceleration.smoothedX value, 456

isKeyDown method, 457

keyAcceleration value, 456

player's velocity, 457

PointMake function, 457

RectMake function, 457

SizeMake function, 457

update method, 455456

workspace

Hello-Kobold2D template, 443

Kobold2D Project Starter.app, 442443

Xcode 4 workspace, 443, 444

Kobold2D.xcworkspace, 443

imagesL

Leaderboards

AppDelegate class, 386

GameKitHelper class, 385

GKLeaderboard object, 384

GKLeaderboardViewController, 386, 387

leaderboardDelegate, 385

loadScoresWithCompletionHandler method, 384

onPlayerInfoReceived method, 382

onScoresReceived method, 384

playerScope variable, 384

Playtime categoy ID, 383

retrieveScoresForPlayers method, 383

retrieveTopTenAllTimeGlobalScores method, 383

RootViewController class, 385386

submitScore method, 382

TileMapLayer class, 382

user interface, 385

leaderboardViewControllerDidFinish method, 385

League of Evil game, 473

Level SVG products, 470

Levels

layers, 127

scenes, 127

loadAchievementsWithCompletionHandler method, 390

loadFriendsWithCompletionHandler method, 381

Local player authentication

authenticateLocalPlayer method, 376

block objects, 377

error handling, 377, 378

Game Center sign-in dialog, 377

iPhone/iPad Simulator, 377

leaderboards, 375

localPlayer object, 377

NSNotificationCenter method, 376

player account, 375

registration, 376

Lua configuration files, 473

Lua functions, 448

Lua table, 448, 451

imagesM

Marketing

App Store, 485

Indie Marketing and Business Tips, 485

public relations and press releases, 487488

your game and yourself, 486487

Matchmaking

addPlayersToMatch, 395

cancelMatchmakingRequest method, 395

CCProgressTimer class, 394

expectedPlayerCount property, 395

GKMatchDelegate, 393

GKMatchRequest instance, 392

host game view, 393, 394

match searching, 394

minPlayers and maxPlayers properties, 392

onMatchFound message, 393

peer-to-peer networking, 392

showMatchmakerWithRequest method, 392393

Model-View-Controller (MVC) pattern, 404

Moment of inertia, 315

MoveBy action, 92

imagesN

NetworkPackets.h file, 397

Neutron, 491

nextInactiveBullet, 151

Node hierarchy, 43

NodeHierarchy project, 48

NSArray method, 97

NSArray subset, 97

NSDictionary class, 391

NSError object, 377, 378

NSEvent class, 63

NSMutableArray class, 97

NSMutableArray method, 97

NSNotificationCenter, 375

NSString, 411

NSString's intValue method, 257

NSStringFromClass method, 220

imagesO

Object pooling, 150

onCallFunc method, 77

onEnter method, 115

onEnterTransitionDidFinish, 117

onFriendsListReceived method, 381

onLocalPlayerAuthenticationChanged method, 380

onReceivedData method, 397

onScoresReceived delegate method, 385

OpenFeint, 490

OpenGL, 128

OpenGL ES framework, 401

openGLView, 434

Optimizations, 150152

Orientation course, autorotation

AppDelegate class, 424

ARMv6, 423

compiler flags, 423

director.openGLView, 427

EAGLView, 427

GameConfig.h file, 423, 425

interfaceOrientation modes, 424, 425

iOS HIG, 423

kGameAutorotationCCDirector, 423425

kGameAutorotationNone, 423, 425

kGameAutorotationUIViewController, 423, 424

kGameAutorotationViewController, 426

RootViewController class, 424, 425, 427

UIViewController, 424

willRotateToInterfaceOrientation method, 426

Orthogonal tilemaps, Cocos2d

CCLOG statement, 256

CCTMXTiledMap class, 254

CCTMXTiledMap method, 256

ccTouchesBegan method, 255

GIDs, 256

iPhone Simulator, 255

layerNamed method, 255

NSDictionary method valueForKey, 256

NSDictionary property, 256

NSString objects, 256

NSString's boolValue method, 256

object layer, 260, 262

object layer rectangles

ccDrawLine, 264

CCTMXObjectGroup, 263

draw and drawRect method, 264

objectGroupNamed method, 263

OpenGL ES code, 262

OpenGL ES codeOpenGL ES code, 262

TileMapLayer class, 263

–(void) draw method, 262, 263

optimization and readability, 260

propertiesForGID method, 256

removeTileAt method, 257

setTileGID method, 257

tileGIDAt method, 256

TileMapLayer class, 254

tilemap scrolling

CCMoveTo action method, 266

CCTMXTiledMap method, 265

centerTileMapOnTileCoord method, 265

scrollPosition CGPoint, 266

tilePosFromLocation method, 256

tilePos method, 256

tile's properties, 255256

touched tiles location

CCLOG and NSAssert lines, 260

coordinate system, 259

noninteger coordinate, 259

tile coordinates, 257

tileMap.mapSize, 260

tileMap.position, 258

tileMap.tileSize property, 259

tilePosFromLocation method, 257

tileSize.height, 260

imagesP

Parallax scrolling, 169

anchorPoint property, 178179

background re-creation, code

background CCSprite, 174

background images, 173

CCLayerColor, 174

CCSpriteBatchNode, 173

CCTextureCache, 173

getNodeByTag method, 173

getTextureByName method, 173

iPad version, 174

ParallaxBackground node, 172

stringWithFormat, 173

TexturePacker, 172

background stripes

Assets folder, individual stripes, 170, 171

image-editing program Seashore, 170

individual parallax layers, 169, 170

iOS devices, fill rate, 172

overdraw, 172

ScrollingWithJoy01 project, 169

TexturePacker, texture atlas, 169171

z-order images, 172

CCParallaxNode, 169

CCTexture2D method setTexParameters, 182

flicker, 180, 181

GL_REPEAT texture parameter, 181, 182

infinite scrolling, 169

numStripes, tag number, 178

off-screen background images, 178

parallax speed factors

CCArray, 175

dealloc method, 177

floatValue method, 178

iOS SDK collection classes, 176

NSNumber numberWithFloat, 176

ParallaxBackground class header, 176

ScrollingWithJoy02 project, 175

scrollSpeed, 177

speedFactors initialization, 176

update method, 177

zOrder property, 177

ParallaxBackground, 174175

repeatRect, 182

update method, endless scrolling, 179180

Particle effects, 217

CCNode objects, 217

CCParticleExplosion, 218

CCParticleSystem (see also CCParticleSystem)

fire.png, 220

motionless, moving slowly and moving fast effect, 217, 218

particle designer

background color settings, 235

cocos2d and iOS OpenGL applications, 234

code duplication, 238

Emitter Config view, 234

endRadiusVar property, 235

iPhone Simulator, 235, 236

Online Library, 239, 240

Particle Texture, 235

particleWithFile method, 238

plist file, 237

positionType property, 235

Ramdomize button, 236

runEffect method, 237

particle system properties, 221

runEffect method, 218

Shoot 'em Up, 240242

trial-and-error process, 217

Peer-to-peer networking, 392

Photon, 491

Physics engines, 297

animation system, 297

Box2D (see Box2D)

Chipmunk

addSomeJoinedBodies, 320

b2RevoluteJoint, 320

boxing-in boxes, 313314

collision course, 317318

collision courseaddSomeJoinedBodies, 319

cpConstraint pointer, 320

cpPivotJointNew, 320

cpSpaceAddConstraint method, 320

Howling Moon Software, 311

Objective-C wrappers, 311

space, 312

SpaceManager API reference, 312

sprite's position and rotation, 316317

Ticky-Tacky little boxes, 314315

contact points, 298

density/mass, 297

dynamic bodies, 297298

friction, 297

iOS games, 297

joints selection, 298

limitations, 298

restitution, 297

rigid bodies, 297

static bodies, 297

PhysicsEditor, 2

application's folder, 323

bumper and ball, 332

flippers, 331332

plunger shape

Add Rectangle button, 326

Delete point, 325

Fixture parameters, 326

Image parameters, 325

manual shape definition, 326

Plunger collision category and mask flags, 326, 327

PNG files, 324

PTM-Ratio, 325

save and publish, 333

table shapes

Ball category, 330

black frame border, 329

Shape Tracer, 328

table-bottom shape, 328

table-left shape, 328

table-top shape, 328330

Tolerance setting, 329, 330

PhysicsEditor tools, 2

Pinball game, 321, 322

applyForceTowardsFinger method, 348

ball class's interface, 344

b2_dynamicBody, 345

BodyNode class

.png extension, 335

CCSprite object, 333

GB2ShapeCache class, 336

header file, 334

implementation file, 335336

initWithShape method, 334

initWithSpriteFrameName method, 336

isKindOfClass method, 334

physics simulation, 338

PinballTable class, 337

TexturePacker, 335

world->Step() method, 337

body->SetTransform method, 346

bodyToFingerDirection vector, 349

Box2D Debug Drawing, 343344

Box2D physics engine, 321

bumpers, 350351

convex and counterclockwise shape, 322323

elements, 321

fingerLocation method, 347

flippers

attachFlipperAt method, 361

ccTouchBegan method, 362

CCTouchDispatcher, 361

EFlipperType enum method, 361

initWithWorld method, 360361

interface, 360

isTouchForMe method, 363

maxMotorTorque and motorSpeed fields, 362

revolute joint, 361362

SetBullet method, 362

gravitational pull simulation, 349

init and dealloc methods, ball class, 345

PhysicsEditor (seePhysicsEditor)

pinball table creation

anchorPoint set, 339

CCSpriteFrameCache, 341

initBox2dWorld method, 342343

PinballTable class, 340

pixel-to-meters macro PTM_RATIO, 341

Retina resolution images, 341

tablePartInWorld method, 338

tablePartInWorld methodTtablePart class implementation, 338

TableSetup class implementation, 339

plunger

applyForceTowardsFinger method, 351

contact events, 358359

CreateJoint method, 353

enableLimit field, 353

header file, 351

initialization, 352

initTableWithWorld method, 353

maxMotorForce, 353

prismatic joint, 352

universal contact listener (see Universal contact listener)

worldAxis, 353

setBallStartPosition method, 346

TablePart objects initialization, 346

touch delegate methods, 347

unit vector, 348

PlayedForTenSeconds achievement ID, 367

player.position, 91

Playtime category ID, 367

Plus+, 490

popScene method, 5556

Portable network graphics (PNG), 88

Prefix.pch header file, 23, 24

pushScene method, 5556

imagesQ

Quexlor game, 471

imagesR

registerForLocalPlayerAuthChange method, 375

reportScoreWithCompletionHandler method, 383

RootViewController class, 368, 413

runWithScene method, 434, 435

imagesS

Sapus Tongue source code project, 470

SBasePacket struct, 398

sceneChanged method, 436

Scene hierarchy, 41

sceneWithTargetScene method, 120

Scheduled messages

_cmd hidden variable, 49

Debugger Console, 48

delta parameter, 47

Objective-C lingo, 47

Objective-C methods, 49

parameters name and number, 49

scheduleUpdate method, 48

tenMinutesElapsed method, 49

undeclared selectors, 48, 49

update methods, 51

–(void) update:(ccTime)delta method, 50

scheduleUpdate method, 48

Scoreloop, 490

Segmented Control buttons, 436

selectedSegmentIndex, 436

sendDataToAllPlayers method, 396, 398

sendSubviewToBack message, 414

setDeviceOrientation method, 425426

setDisplayFPS, 434

setLastError method, 377, 378

setOpenGLView, 434

sharedGameScene accessor, 150

sharedManager static method, 78

Shoot 'em Up, 195

base Entity class, 200

boss monster, 213

BulletCache class

BulletCache header file, 195

BulletCache instance, 198

bullet-shooting code, 196

bullets reuse, 196197

CCNode getChildByTag method, 196

CCSpriteBatchNode, 195

CGRectIntersectsRect method, 197

CGRectIsEmpty method, 198

interface, 195, 196

setDisplayFrame method, 197

shootBulletAt method, 197

update method, 198

CGRectIntersectsRect test, 212

checkForBulletCollisions method, 212

clean code design, 199

collisions with bullets, 211212

component-based programming, 195

EnemyTypeBoss, 215

Entity class hierarchy (see Entity class hierarchy)

game's enemy characters, 199

HealthBarComponent, 213

isEnemyBulletCollidingWithRect method, 211

isPlayerBulletCollidingWithRect method, 211

Objective-C programming language, 200

onHit method, 214

plug-and-play solution, 213

spawn method, HealthbarComponent, 215

update method, 214

shootBulletFromShip, 152

shouldAutorotateToInterfaceOrientation method, 424435

SimpleAudioEngine, 108

SmartFoxServer, 491

SneakyInput

AppDelegate class, 184

classes, 184, 185

cocos2d version, 183

ColoredCircleSprite class, 183

Download Source button, 183

GitHub, 183

HelloWorldScene class, 184

iPhone Simulator, 183

open source software, 183

SneakyInput Xcode project, 183

textures, 184

SoundConverter, 108

Sprites, 141

animations

addImage method, 153

CCAnimate action, 153

CCAnimationCache class, 153

CCRepeatForever action, 153

CCSpriteFrame, 153

CCTexture2D objects, 153

contentSize property, 153

HD and SD resolution, 152

helper category, 154156

ship's animation, 152

texture atlas, 152153

batching, 141

CCSpriteBatchNode

batch rendering, 144

CCSprite nodes, 144, 145

disadvantages, 145

error message, Debugger Console window, 145

functions, 141

Sprites01 project, 146

Sprites02 project, 147148

Sprites03 project, 148150

Sprites04 project, 150152

texture, 144

texture atlas, 145

draw call, 141

Retina display

CCDirector method, 144

HD image, 143

HD graphics, 142

PowerVR MBX Lite, 142

resolution-independent coordinate system, 142

SD images, 143

ship-hd.png, 143

subpixel rendering, 143

technical specifications iOS devices, 142

texture atlas, 141

CCAnimation helper category updation, 165166

CCSpriteBatchNode, 156

CGRect structure, 157

dimensions, 166

LoadingScene, 166

memory, 166

purge methods, 167

removeUnused methods, 167

texture size, 156

TexturePacker (seeTexturePacker)

with cocos2d, 163164

SScorePacket, 398

Standard-definition (SD) graphics, 142

StandardShootComponent method, 209211

startAnimation method, 435

stopAnimation method, 435

switchChanged method, 433, 434

imagesT

textFieldFront, 419

TexturePacker

creation

Assets folder, 159

banding effect, 163

Border Padding settings, 161

color depth, 162

Dithering option, 163

GameArt folder, 159

HD texture, 160, 161

Image Format setting, 162

Output settings, 161

PNG file format, 162

PVR format, 162

RGB5551 format, 162

RGB565 format, 163

RGBA4444 format, 162

RGBA8888 format, 162

SD texture, 160

Shape Padding settings, 161

Sprites06 project, 161

stray pixels, 161

Texture Format, 162

transparent border pixels, 160

true-color image, 162

working process, 159, 160

2D sprite-packing tool, 157

iPhone's PowerVR graphics chip, 157

preparation, 158

ship's animation frames, 157

Terminal app, 157

TexturePacker Pro, 157

TexturePacker tools, 2

Tiled (Qt) Map Editor

tilemap creation

dg_grounds32.png tileset, 249

Margin and Spacing settings, 250

New Map dialog, 248

New Tileset dialog, 249, 250

texture atlas, 249

tile size, 249

TMX file, 250

tilemap design

blank map, 251

Bucket Fill (hotkey F), 252

choose Layer, 252

dg_grounds32 tileset, empty map, 251

edit properties, 252

Eraser (hotkey E), 252

GameEventLayer, 252, 253

Insert Objects (hotkey O), 252

Insert Tile Objects (hotkey T), 252

isWater property, 252, 253

Layers view, 252

Rectangular Select (hotkey R), 252

Remove Object, 252

Select Objects (hotkey S), 252

Stamp Brush (hotkey B), 252

tile layers and object layertile and object layers, 253, 254

TMX files, 248

Tiled editor, 12

Tiled map editor, 473

ground rules, 276278

new isometric tileset creation, 276

New Map dialog, 273, 274

plain-text XML file, 275

tile-size offset problem, 274, 275

tilewidth and tileheight parameters, 275

TMX file, 275

TileMapLayer class, 380

TileMapLayer's update method, 389

Tilemaps, 243

2D game world, 243

Farmville game, 246

isometric tilemap, 245, 246

multiple layers, 244, 245

orthogonal tilemaps, Cocos2d (see Orthogonal tilemaps, Cocos2d)

TexturePacker image preparation, 247248

Tiled (Qt) Map Editor (see Tiled (Qt) Map Editor)

tiles, definition, 243

TileMapScene class, 397

TMX file format, 12

Touch events propagation

boundingBox, 417, 418

CCARRAY_FOREACH loop, 418

CCLayer class, 418

CCMenuItem, 418

CCNode class, 418

CCScene class, 418

CCTouchDispatcher class, 415, 416

EAGLView class, 416, 417

glView, 415

hitTest method, 417

hitTestNodeChildren method, 417

runningScene, 417

sceneChildren, 417

UIView hitTest event, 416

userInteractionEnabled, 416

Twitch-based game, 27

Twitter, 487

imagesU

UIAccelerometer interface, 455

UIAlertViewDelegate protocol, 405, 409

UIApplicationDelegate class, 447

UIApplicationDelegate protocol, 25

UIImage class, 410412

UIImagePickerController, 458

UIKit views, 3

CCMenu, 401

CCSprite, 401

Cocoa Touch (see Cocoa Touch)

cocos2d

addSomeCocoaTouch method, 407, 408

CCDirector, 409

CCLabelTTF, 406

CocosWithCocoa03 project, 408

didDismissWithButtonIndex message, 407

dummyView, 414

EAGLView class, 409

glView, 409

HelloWorldLayer class, 405, 407, 408

init method, 406

Interface Builder (see Interface Builder)

openGLView, 406

orientation course, autorotation (see Orientation course, autorotation)

PrivateMethods interface, 405

removeFromSuperview message, 410

resignFirstResponder message, 410

RootViewController class, 408

sandwiching, 418419

textFieldDidBeginEditing message, 410

textFieldShouldReturn message, 409, 410

touch events propagation (seerouch events propagation)

UIAlertView, 405, 407

UIAlertViewDelegate methods, 407

UIAlertViewDelegate protocol, 405

UITextField, 408, 409, 414

UITextField and UIImage skinning, 410412

UITextFieldDelegate protocol, 409

view hierarchy, 412413

view transparent, 414415

UISegmentedControl, 436

UITextField views, 403, 411, 412

UITextFieldDelegate protocol, 409, 410

UIView-based classes, 405

UIViewController, 368

UIWindow, 405, 413

Universal contact listener

BeginContact and EndContact methods, 355

beginContactWithBall selector, 357

Box2D collision process, 354

Box2D Contact method implementation, 355356

ContactListener class definition, 354

interface and implementation, 357358

notifyAB method, 356

NSStringFromClass method, 356

retain method, 358

imagesV

VertexHelper, 2

View-based Application, 437

AudioToolbox.framework, 430

AVFoundation.framework, 430

Build Phases tab, 429

cocos2d libs folder, 429

iOS Deployment Target, 428

libz.dylib, 430

Link Binary With Libraries pane, 429, 430

MainWindow.xib file, 427

OpenAL.framework, 430

OpenGLES.framework, 430

Project Navigator pane, 428, 429

QuartzCore.framework, 430

template, 427, 428

ViewBasedAppWithCocos2D project, 427429

Xcode 4, 429

ViewBasedAppWithCocos2D-Prefix.pch file, 432

ViewBasedAppWithCocos2DViewController class, 432, 435, 436

ViewBasedAppWithCocos2DViewController.m file, 433

ViewBasedAppWithCocos2DViewController.xib file, 430

ViewBasedWithCocos2DViewController.h file, 432

viewController view, 413

Virtual joypad, 182

addJoystick method, 190

autoCenter, 190

cocos2d's ccpMult method, 191

defaultShip accessor method, 191

digipad/thumbstick, 182

digital controls, 193

GameScene class, 191

setPosition method, 192

setRotation:(float)rotation method, 192

shoot button

addFireButton method, 186

buttonRadius, 187

CCLayer, 185

CGRect parameter, 186

CGRectZero, 186

Debugger Console window, 187

GameScene class, 185

GameScene header file, 186

InputLayer.h header file, 186

scene method, 185, 186

update method, 187

skinned analog thumbstick and fire button, 182

skinning

activated state image, 188

addFireButton method, 188189

ccTime variables, 189

cocos2d-style static initializers, 187

default state image, 188

disabled state image, 188

fireButton, 188

pressed state image, 188

shooting bullets, fire button, 189

SneakyButton autorelease initializers, 188

SneakyButtonSkinnedBase class, 189

SneakyExtensions class, 187, 188

SneakyInput (seeSneakyInput)

SneakyJoystick, 190

SneakyJoystickSkinnedBase, 190

update method process, 191

velocity property, 191

imagesW

willRotateToInterfaceOrientation method, 426

imagesX

.xcconfig files, 446

Xcode 4, 2

.xcodeworkspace file, 444

imagesZ

zOrder property, 175

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.132.99