Index

image Numbers and Special Characters

2D transformations, 334345

combining of, 343345

and matrices, 335336

rotating, 341342

scaling, 342

using translation, 336341

world space vs. model space, 334335

3D in OpenGL ES, 495531

blending, 507510

camera system for, 527530

matrices, 517530

hierarchical systems with, 520526

matrix stack, 518520

perspective projection, 502504

triangle meshes, 511517

vertices in, 496501

z-buffer, 505507, 510511

z-fighting, 510511

3D programming, 533585

cameras, 561572

Euler, 562570

look-at, 571572

collision detection and object representation in, 581584

bounding shapes in 3D programming, 581583

GameObject3D and DynamicGameObject3D classes, 583584

introduction to, 533534

lighting in OpenGL ES API, 538556

description of, 538540

enabling and disabling, 543

example of, 552556

limitations of, 556

materials, 541, 547548

sources of, 540547

vertex normals, 542552

loading models, 573580

limitations of, 579580

OBJ loader, 574579

Wavefront OBJ format, 573574

mipmapping, 557561

physics in, 580581

vectors, 534538

image A

accelerometer state, reading, 146151

AccelerometerHandler handler, AndroidInput implementation and, 202204

accelHandler.getAccelX( ) method, 220

accelHandler.getAccelY( ) method, 220

accelHandler.getAccelZ( ) method, 220

action games, and arcade games, 5861

active matrices, and matrix modes, 298

activities

AndroidBasicsStarter, 121123

life cycle of, 125132

in practice, 129132

in theory, 125128

starting programmatically, 123124

test, 124125

Activity class, 121, 124, 128, 152, 235236, 292

<activity> element, 111113

activity.getAssets( ) method, 198

Activity.isFinishing( ) method, 130

Activity.onCreate( ) method, 37, 126, 159, 167

Activity.onStart( ) method, 126

Activity.onStop( ) method, 126

ADB (Android Debug Bridge) tool, 5051

ADB command, 51

add( ) method, 363, 365, 536

addScore( ) method, 245

ADT (Android Development Tools) plug-in, 2830

advance( ) method, 264

alpha blending, in OpenGL ES, 329333

alpha compositing, and blending, 9194

ambient light, 543544

AmbientLight( ) method, 553, 628

Android 1.5, optimizing OpenGL ES, 347

Android Debug Bridge (ADB) tool, 5051

Android Development Tools (ADT) plug-in, 2830

Android Market, 45

Android Market website, putting game on, 642645

marketing, 645

Product Details section, 644

Publish button, 645

Publishing Options panel, 644645

uploading assets, 643644

Android Open Source Project, 4

Android Package Kit (APK) files, 38, 41, 79, 635, 637641, 650

Android SDK, 2552

applications, 3951

ADB tool, 5051

AVDs, 3940

connecting device, 39

debugging, 4447

LogCat system and DDMS, 4850

running, 4144

Hello World project, 3338

structure of, 3436

writing application code, 3638

IDE, 2533

Eclipse platform, 2833

JDK, 26

Android Virtual Devices (AVDs), 3940

AndroidAudio interface, and AndroidSound and AndroidMusic interfaces, 197202

AndroidAudio.newMusic( ) method, 199

AndroidAudio.newSound( ) method, 198

AndroidBasicsStarter activity, 121123, 126

AndroidBasicsStarter class, 122123, 125, 129

AndroidFastRenderView class, 231234

AndroidFileIO class, 196197

AndroidFileIO.getAssets( ) method, 235, 293

AndroidGame class, 100, 234238, 290293

AndroidGame parameter, 232

AndroidGame.setScreen( ) method, 238

AndroidGraphics interface, and AndroidPixmap interface, 221234

AndroidFastRenderView class, 231234

handling different screen sizes and resolutions, 221226

AndroidGraphics.getAssets( ) method, 235

AndroidInput class, 212, 236, 293

AndroidInput implementation, 202204, 219221

AndroidManifest.xml file, 44, 109, 117

AndroidMusic class, 199200, 202

AndroidMusic interface, and AndroidAudio and AndroidSound interfaces, 197202

AndroidPixmap interface, AndroidGraphics interface and, 221234

AndroidFastRenderView class, 231234

handling different screen sizes and resolutions, 221226

AndroidSound class, 199

AndroidSound interface, and AndroidAudio and AndroidMusic interfaces, 197202

angle( ) method, 365, 368, 538

animating, sprites, 427433

Animation class, 428429

example of, 429433

Animation class, 428

AnimationScreen class, 430

AnimationTest class, 430

API class, 365

APIs (Application Programming Interfaces), 121192

activity life cycle, 125132

in practice, 129132

in theory, 125128

file handling, 152158

accessing external storage, 154157

reading asset files, 152154

shared preferences, 158

input device handling, 132151

multitouch events, 132136, 143

processing key events, 143146

reading accelerometer state, 146151

reading compass state, 151

single-touch events, 132136

playing sound effects, 159162

programming

audio, 158159

graphics, 167192

streaming music, 163166

test project, 121125

APK (Android Package Kit) files, 38, 41, 79, 635, 637641, 650

application and window management modules, 74

<application> element, 110111

application framework, 910

Application Programming Interfaces. See APIs

applications, 3951

ADB, 5051

AVDs, 3940

connecting device, 39

debugging, 4447

LogCat system and DDMS, 4850

manifest file, 108121

<activity> element, 111113

<application> element, 110111

<manifest> element, 109

<uses-feature> element, 114116

<uses-permission> element, 113114

<uses-sdk> element, 116

defining game icon, 119121

market filters, 119

steps to set up game project, 117118

running, 4144

testing, 635636

writing code for, Hello World project, 3638

arcade games, action games and, 5861

art style, for Super Jumper game, 436437

art styles

and backstory, for Droid Invaders game, 589590

stories and, 6667

aspect ratios, 222225

asset files, reading, 152154

assetDescriptor.getLength( ) method, 200

assetDescriptor.getStartOffset( ) method, 200

AssetManager.openFd( ) method, 159, 198

assets

for Droid Invaders game, 593596

sound and music, 596

UI assets, 593596

fetching from disk with LoadingScreen class, 246

for Mr. Nom game, 239241

store for, 242243

in Super Jumper game, 441449

game elements, 445447

sounds, 448449

text with bitmap fonts, 443445

texture atlas, 447

UI elements, 441442

uploading, 643644

Assets class

for Droid Invaders game, 597599

in Super Jumper game, 450452

Assets.invaderModel.bind( ) method, 629630

Assets.invaderModel.getNumVertices( ) method, 630

Assets.invaderModel.unbind( ) method, 630

Assets.invaderTexture.bind( ) method, 629630

Assets.load( ) method, 455

Assets.music.pause( ) method, 459, 602, 606

Assets.music.play( ) method, 459, 606

Assets.playSound( ) method, 460, 473

Assets.reload( ) method, 455, 602

Assets.shieldModel.bind( ) method, 630

Assets.shieldModel.getNumVertices( ) method, 630

Assets.shieldModel.unbind( ) method, 630

Assets.shipModel.bind( ) method, 629

Assets.shipModel.getNumVertices( ) method, 629

Assets.shipModel.unbind( ) method, 629

Assets.shipTexture.bind( ) method, 629

Assets.shotModel.bind( ) method, 630

Assets.shotModel.getNumVertices( ) method, 631

Assets.shotModel.unbind( ) method, 631

audio, 7983, 158159

physics of sound, 80

playing sound effects, 159162

in practice, 8283

quality and compression, 8182

recording and playback, 8081

setting volume controls, 158159

streaming music, 163166

Audio interface, 82

Audio( ) method, 98

Audio.newMusic( ) method, 82

Audio.newSound( ) method, 83

AVDs (Android Virtual Devices), 3940

awesomePic.dispose( ) method, 102

awesomePic.getHeight( ) method, 102

awesomePic.getWidth( ) method, 102

image B

background.reload( ) method, 452, 599

backstories, and art style, 589590

ballVertices.bind( ) method, 377, 404, 414

ballVertices.unbind( ) method, 377, 404, 414

batcher.beginBatch( ) method, 424

batcher.drawSprite( ) method, 419

batcher.endBatch( ) method, 419, 424, 432, 460, 465, 490, 604, 607, 625, 631

beginBatch( ) method, 421

benchmarking, Super Jumper game, 492493

best practices, 192

bind( ) method, 322, 354, 497498, 550551, 560

Bitmap class, 178

bitmap fonts, text with, 443445

Bitmap.Config file, 182

Bitmap.drawBitmap( ) method, 224

BitmapFactory.decodeStream, 315, 318319

BitmapFactory.Options class, 179, 321

BitmapFactory.Options( ) method, 179, 181

bitmap.getConfig( ) method, 178, 229, 560

bitmap.getHeight( ) method, 178, 227, 559560

bitmap.getWidth( ) method, 178, 227, 559560

Bitmap.recycle( ) method, 179, 183, 227, 317319, 559560

bitmaps, 178183

demonstration of, 180183

disposing of, 179

drawing, 179180

loading and examining, 178179

for texture mapping, 315316

BitmapTest activity, 180

blending

3D in OpenGL ES, 507510

alpha compositing and, 9194

Bob class, in Super Jumper game, 471473

Bob( ) method, 337339

bob.hitPlatform( ) method, 477, 479

bob.hitSpring( ) method, 480

bob.hitSquirrel( ) method, 479

bobModel.bind( ) method, 355

bobModel.unbind( ) method, 355

BobScreen class, 339, 346

BobScreen.present( ) method, 344, 346

BobScreen.resume( ) method, 349

BobTest method, 425

bobTexture.bind( ) method, 340, 349350

bobTexture.reload( ) method, 350

Bob.update( ) method, 477

Boolean.parseBoolean, 244, 453454, 600

bottomText.length( ) method, 488

bounding shapes

in 3D programming, 581

bounding sphere overlap testing, 582583

for collision detection, 379383

bounds.width( ) method, 185

broad phase, collision detection, 390391

buffer.asFloatBuffer( ) method, 302, 327

buffer.asIntBuffer( ) method, 426, 497, 550

buffer.asShortBuffer( ) method, 327, 497, 550

buffering, double, vsync and, 8687

buffer.order, 302, 327, 497, 550

builder.appendevent.getKeyCode( ) method, 145

builder.appendevent.getX( ) method, 134

builder.appendevent.getY( ) method, 134

builder.toString( ) method, 134, 145

ByteArrayOutputStream( ) method, 153

ByteBuffer.allocateDirect( ) method, 309

byteBuffer.asFloatBuffer( ) method, 303, 306, 309, 311, 314, 319, 324

byteBuffer.asShortBuffer( ) method, 323, 325

byteBuffer.orderByteOrder.nativeOrder( ) method, 303, 306, 309, 311, 314, 319, 323325

ByteOrder.nativeOrder( ) method, 302, 327, 497, 550

image C

calculateInputAcceleration( ) method, 623624

calledglOrthof( ) method, 301

camera.getDirection( ) method, 567

camera.getLookAt( ) method, 628

camera.getPosition( ) method, 567, 628

cameras, 561572

in 2D, 404410

in 3D, 527530

Euler, 562570

look-at, 571572

camera.setViewportAndMatrices( ) method, 409, 414, 424, 432

cam.setViewportAndMatrices( ) method, 489

Cannon class, 392, 400, 402, 413

CannonTest class, 368

cannonVertices.bind( ) method, 377, 404, 414

cannonVertices.draw( ) method, 414

cannonVertices.unbind( ) method, 377, 404, 414

Canvas class, 170, 172173, 179, 225, 558, 560

canvas, hardware-accelerated rendering with, 191192

Canvas method, 174, 183

Canvas.drawBitmap( ) method, 225, 230, 233

canvas.drawCirclecanvas.getWidth( ) method, 176

Canvas.drawLine( ) method, 230

Canvas.drawPoint( ) method, 230

Canvas.drawRect( ) method, 230

Canvas.drawRGB( ) method, 229

Canvas.getClipBounds( ) method, 233

canvas.getHeight( ) method, 172, 176

canvas.getWidth( ) method, 172, 176, 185186

Castle class, in Super Jumper game, 468

Caveman class, 430

Caveman.update( ) method, 431

challenges, device seeding program, 56

checkBitten( ) method, 265, 269

checkCastleCollisions( ) method, 478, 480

checkCollisions( ) method, 477478

checkGameOver( ) method, 477, 481

checkInvaderCollisions( ) method, 616617

checkItemCollisions( ) method, 478, 480

checkPlatformCollisions( ) method, 478479

checkShotCollisions( ) method, 616, 618619

checkSquirrelCollisions( ) method, 478480

children.size( ) method, 523

Circle class, 385, 582

circles

collision of, 385386

drawing, 175

Class.forName( ) method, 124

cleanupResources( ) method, 98

clear( ) method, 229, 303

clearDynamicCells( ) method, 398

Coin class, in Super Jumper game, 467468

coin( ) method, 473, 483

coins.size( ) method, 478, 480

colliders.size( ) method, 402

collision detection, 378404

bounding shapes for, 379383

broad phase, 390391

example of, 391404

narrow phase, 385390

circle and rectangle collision, 387389

circle collision, 385386

rectangle collision, 386387

and object representation in 3D programming, 581584

bounding shapes, 581583

GameObject3D and DynamicGameObject3D classes, 583584

in Super Jumper game, 478480

CollisionScreen class, 409

CollisionTest class, 402

CollisionTest file, 409

Color class, 174

colors

description of, 87

encoding digitally, 8990

models of, 8788

specifying for vertices, 309312

combining, of 2D transformations, 343345

compass state, reading, 151

CompassHandler handler, 204221

AndroidInput implementation, 219221

KeyboardHandler handler, 207211

Pool class, 205207

touch handlers, 211219

MultiTouchHandler class, 215219

SingleTouchHandler class, 212215

TouchHandler interface, 212

compatibility, across all devices, 1920

compositing alpha, and blending, 9194

compression

audio quality and, 8182

image formats and, 9091

Config class, 229

connectivity, permanent, 2122

Context interface, 124, 147, 152, 159

Context parameter, 219

context.getAssets( ) method, 152, 181, 196

Context.getExternalFilesDir( ) method, 245

continuous rendering, with SurfaceView class, 186192

checking surface validity, 187188

demonstration of, 188191

reason for using, 187

SurfaceHolder class and locking, 187

controllers, for games, 1819

coordinate systems, screen resolution and, 172173

cpy( ) method, 364, 535536

crateTexture.bind( ) method, 568

crateTexture.reload( ) method, 567

createCube( ) method, 515516, 524, 553554, 566567, 579

createMipmaps( ) method, 559560

createObject( ) method, 206207, 209, 213, 216

createWindowAndUIComponent( ) method, 98

cube.bind( ) method, 516, 525, 555, 568

CubeScreen class, 515

CubeTest class, 515

cube.unbind( ) method, 516, 526, 555, 569

currentTime( ) method, 98

image D

Dalvik Debugging Monitor Server (DDMS), LogCat system and, 4850

Dalvik VM, runtime and, 78

DDMS (Dalvik Debugging Monitor Server), LogCat system and, 4850

debugging

ADB tool, 5051

applications, 4447

decodeStream, 315, 318319

density, 222

descriptor.getLength( ) method, 163, 165

descriptor.getStartOffset( ) method, 163, 165

developer community, 1112

developer console, 645646

device seeding program, challenges, 56

devices, 1219

AVDs, 3940

compatibility across all, 1920

connecting, 39

cutting-edge, 1617

hardware specifications, 1213

next generation of, 1718

range of, 1419

cutting-edge devices, 1617

game controllers, 1819

minimum target, 1416

next generation of devices, 1718

ubiquity of mobile, 2021

direct NIO buffers, 302303

directional lights, 546547

DirectionalLight( ) method, 553, 628

disable( ) method, 546

dispose( ) method, 96, 200, 247, 251, 257, 322, 432, 488, 561, 626

dist( ) method, 386, 389, 538

distSquared( ) method, 386, 389, 538

double-buffering, vsync and, 8687

draw( ) method, 328, 551

drawGameOverUI( ) method, 274, 276

drawLine( ) method, 230

drawPausedUI( ) method, 274276

drawPixel( ) method, 230

drawPixmap( ) method, 228, 230231

drawReadUI( ) method, 276

drawReadyUI( ) method, 274275

drawRect( ) method, 230

drawRunningUI( ) method, 274276

drawText( ) method, 184, 186, 256, 276, 457

drawWorld( ) method, 275

Droid Invaders game, 587633

assets, 593596

sound and music, 596

UI, 593594

Assets class, 597599

backstory and art style, 589590

coding, 596597

core game mechanics, 587589

defining world of, 591593

GameScreen class, 620626

main activity, 601602

main menu screen, 602604

optimizations, 632633

screens and transitions, 590

Settings class, 600601

settings screen, 604607

simulation classes, 607619

Invader, 611614

Shield, 608

Ship, 609611

Shot, 608609

World, 614619

WorldRender class, 626631

DroidInvaders activity, 604

DroidInvaders class, 599

dynamicCells[cellId].size( ) method, 398

dynamicCells[i].clear( ) method, 397

DynamicGameObject class, 392, 433, 583

DynamicGameObject3D class, GameObject3D class and, 583584

image E

eat( ) method, 264

Eclipse platform

description of, 3032

installing

ADT plug-in, 2830

overview, 28

shortcuts for, 3233

editor.commit( ) method, 158

e.getMessage( ) method, 156, 161, 165

enable( ) method, 546, 548, 555

endBatch( ) method, 421

engines, frameworks and, 648650

Environment class, 155

Environment.getExternalStorageDirectory( ) method, 155156, 196

Environment.getExternalStorageState( ) method, 155156

e.printStackTrace( ) method, 122, 201

ES method, 290, 306, 347, 352, 426, 529

EulerCamera class, 562, 565566

EulerCamera.getDirection( ) method, 566

EulerCamera.rotate( ) method, 568

event logging, LogCat system, 4850

event.getAction( ) method, 134, 137138, 140141, 144, 161, 209, 214, 216

event.getPointerCount( ) method, 140, 216

event.getUnicodeChar( ) method, 145, 209

events.size( ) method, 603, 606, 622624

explosion( ) method, 614, 621

explosionTexture.reload( ) method, 599

external storage, accessing, 154157

externalDir.getAbsolutePath( ) method, 156

image F

factory.createObject( ) method, 206

fans, in OpenGL ES, 333334

FastMath class, 365

FastMath.cos( ) method, 366, 376

FastMath.sin( ) method, 366, 376

FastRenderView class, 190, 231

FastRenderView.pause( ) method, 189190, 233

FastRenderView.resume( ) method, 189190, 232

file handling, 152158

accessing external storage, 154157

reading asset files, 152154

shared preferences, 158

file I/O, 79

FileIO interface, 196197

first-person camera, 562570

FirstTriangleScreen class, 306

FirstTriangleTest class, 306

flip( ) method, 304

float lines.size( ) method, 575

FloatBuffer, working around bug in, 426427

floatBuffer.clear( ) method, 303

floatBuffer.flip( ) method, 303

Font class, in Super Jumper game, 456457

Font.drawText( ) method, 464465

fonts

drawing text with, 183184

loading, 183

force, and mass, 372373

foundObjects.clear( ) method, 398

foundObjects.contains( ) method, 398

FPSCounter( ) method, 622

fpsCounter.logFrame( ) method, 349350, 353, 355

FPSCounter.logFrame( ) method, 492

fpsCounter.logFrame( ) method, 625

fragmentation, 34

frame-independent movement, 103104

frame rate, optimizing OpenGL ES, 345347

frame rates, frame-independent movement, 103104

frameBuffer.getHeight( ) method, 231

frameBuffer.getWidth( ) method, 231

framebuffers, pixels, rasters and, 8485

frameworks, and engines, 648650

free( ) method, 207

freeObjects.removefreeObjects.size( ) method, 206

full-screen view, 168169

image G

game controllers, 1819

game framework, 195238

AndroidAudio, AndroidSound, and AndroidMusic interfaces, 197202

AndroidFileIO class, 196197

AndroidGame class, 234238

AndroidGraphics and AndroidPixmap interfaces, 221234

AndroidFastRenderView class, 231234

handling different screen sizes and resolutions, 221226

AndroidInput implementation and AccelerometerHandler handler, 202204

CompassHandler handler, 204221

AndroidInput implementation, 219221

KeyboardHandler handler, 207211

Pool class, 205207

touch handlers, 211219

game icons, defining, 119121

Game interface, 99101, 197, 234235, 237, 290, 358

game over state, in Super Jumper game, 481

game screen, in Super Jumper game, 481489

rendering, 486488

updating, 483486

game world, of Super Jumper game, 438441

game.getAudio( ) method, 246, 451452, 599

Game.getCurrentScreen( ) method, 100

game.getCurrentScreen( ) method, 233

Game.getFileIO( ) method, 197, 315, 318319, 575

game.getGLGraphics( ) method, 297, 306, 319, 324, 339, 368, 401, 431, 458, 577

game.getGraphics( ) method, 102, 243, 246, 248, 250, 254, 256, 274276

game.getInput( ) method, 248, 252, 307, 375, 459, 484485, 605, 622, 624

Game.getStartScreen( ) method, 100, 234, 306

GameObject class, 392, 466467

GameObject3D class, and DynamicGameObject3D class, 583584

GameObject(float)Math.random( ) method, 393, 401

gamers, casual and hardcore, 22

GameScreen class, 251, 270277, 481, 492, 620626, 632

GameScreen.present( ) method, 486

GameScreen.render( ) method, 492

Game.setScreen( ) method, 100101, 249

GC activity, 621

generateInvaders( ) method, 615616

generateLevel( ) method, 474475

generateShields( ) method, 615616

genres, 5463

action and arcade games, 5861

casual games, 5456

innovative games, 6263

puzzle games, 5657

tower-defense games, 61

getAccelX( ) method, 77, 203, 220, 485

getAccelY( ) method, 77, 203, 220, 624

getAccelZ( ) method, 78, 203, 220

getAssets( ) method, 153, 161, 165

getAudio( ) method, 99, 237, 296

getCellIds( ) method, 397398

getConfig( ) method, 181

getCurrentScreen( ) method, 100, 238, 296

getDeltaTime( ) method, 372374, 580

getDirection( ) method, 564

getFileIO( ) method, 99, 237, 295

getFormat( ) method, 96, 227

getGL( ) method, 291

getGLGraphics( ) method, 295, 297, 311, 319, 330, 339, 375, 401, 431, 458

getGraphics( ) method, 99, 237, 295

getHeight( ) method, 9596, 172, 227, 231, 235, 291

getHolder( ) method, 188, 232

getIndex( ) method, 577578

getInput( ) method, 99, 237, 295

getKeyEvents( ) method, 78, 205, 211, 248, 256, 307, 369, 402, 462, 464

getKeyFrame( ) method, 429

getLookAt( ) method, 572

getNumIndices( ) method, 579

getNumVertices( ) method, 579

getOrientation( ) method, 150

getPitch( ) method, 205, 563

getPosition( ) method, 563, 572

getPotentialColliders( ) method, 396, 398

getPreferences( ) method, 197

getResources( ) method, 235236

getRoll( ) method, 205

getRotation( ) method, 150

getStartScreen( ) method, 100, 234235, 238, 242, 296, 339, 455, 552, 602

getTouchEvents( ) method, 205, 215, 219, 248, 307, 402, 462, 486, 622, 624

getTouchX( ) method, 215, 218, 367

getTouchY( ) method, 215, 367

getUp( ) method, 572

getWidth( ) method, 9596, 172, 227, 231, 235, 291

getWindow( ) method, 168, 171, 176, 181, 185, 188, 235, 289, 292

getWindowManager( ) method, 235

getYaw( ) method, 205, 563

g.getHeight( ) method, 249, 274

g.getWidth( ) method, 274

glBindTexture( ) method, 315316

glBlendFunc( ) method, 329330

glClear( ) method, 290, 308, 506

glClearColor( ) method, 290, 349

glClearColor.nextFloat( ) method, 289, 297

glColorPointer( ) method, 310312, 314, 347, 549

glDisableClientState( ) method, 318, 328

glDrawArrays( ) method, 305, 308, 320, 324, 328, 333, 348, 356

glDrawElements( ) method, 310, 328, 333, 347348, 356

glEnable( ) method, 318, 320, 349, 505, 514, 632

glEnableClientState( ) method, 304, 308309, 314, 318, 324, 353, 355

glFrustumf( ) method, 503

GLGame class, 290297, 306309, 409, 601

GLGame interface, 626

glGame.getFileIO( ) method, 321, 558

GLGame.getGLGraphics( ) method, 296, 307

glGame.getGLGraphics( ) method, 321, 558

GLGame.getInput( ) method, 367

glGenTextures( ) method, 317

GLGraphics method, 296

glGraphics.getGL( ) method, 297, 328, 340, 376, 408, 424, 604, 624, 626, 628

glGraphics.getHeight( ) method, 301, 307, 500, 504, 508, 516, 525, 554555, 566

glGraphics.getWidth( ) method, 349, 369, 402, 408, 504, 508, 525, 566, 568, 628

glIdentityf( ) method, 537

glLightModelfv( ) method, 543

glLoadIdentity( ) method, 338, 344, 350, 353, 369, 506, 516, 519, 555, 572

glMaterialfv( ) method, 548

glMatrixMode( ) method, 353, 519

glNormalPointer( ) method, 549, 551

glOrtho( ) method, 504

glOrthof( ) method, 299300, 334, 336, 343, 404, 406, 409, 433, 503

glPopMatrix( ) method, 519520, 522523, 569, 629631

glPushMatrix( ) method, 519520, 522523, 569, 629631

glRotatef( ) method, 341342, 349, 352, 369, 515, 520, 534, 537, 555

glScalef( ) method, 341343, 349, 352, 556

GLScreen, in Super Jumper game, 457458

GLScreen.update( ) method, 484

GLSurfaceView class, 287290

GLSurfaceView method, 289

GLSurfaceView.onPause( ) method, 288

GLSurfaceView.onResume( ) method, 288

GLSurfaceView.Renderer interface, 292

glTexCoordPointer( ) method, 314

glTexEnv( ) method, 330

glTexParameterf( ) method, 316

glTranslate( ) method, 426

glTranslatef( ) method, 336, 338, 343, 356, 377, 517, 520, 526, 537, 631

GLU.glLookAt( ) method, 529

GLU.gluPerspective( ) method, 504, 529

gluLookAt( ) method, 529, 552, 555, 572

gluPerspective( ) method, 503, 555, 562, 564

GLUtils class, 316

glVertexPointer( ) method, 304305, 308, 310311, 314, 324, 347, 498, 549

glView.getHeight( ) method, 291

glView.getWidth( ) method, 291

glView.onPause( ) method, 289, 295

glView.onResume( ) method, 289, 293

glViewport( ) method, 349

glViewportf( ) method, 406

glXXXPointer( ) method, 347, 353, 355

Google

I/O conference, 56

role of, 46

Android Market, 45

Android Open Source Project, 4

challenges, device seeding program, 56

graphics, 8497, 167192

alpha compositing and blending, 9194

bitmaps, 178183

demonstration of, 180183

disposing of, 179

drawing, 179180

loading and examining, 178179

colors

description of, 87

encoding digitally, 8990

models of, 8788

continuous rendering in UI thread, 169172

drawing shapes, 173177

circles, 175

demonstration of, 175177

lines, 174

pixels, 173174

rectangles, 174175

going full-screen, 168169

image formats and compression, 9091

in practice, 9497

rasters, pixels, and framebuffers, 8485

rendering

continuous, 186191

hardware-accelerated with canvas, 191192

text, 183186

screen resolution and coordinate systems, 172173

vsync and double-buffering, 8687

wake locks, 167

Graphics interface, 95, 228, 290

Graphics( ) method, 98

Graphics.clear( ) method, 9596, 250

Graphics.drawLine( ) method, 96

Graphics.drawPixel( ) method, 9596

Graphics.drawPixmap( ) method, 96, 104, 241, 253

Graphics.drawRect( ) method, 96

Graphics.getHeight( ) method, 96, 367, 407

Graphics.getWidth( ) method, 96, 367, 407

Graphics.newPixmap( ) method, 95, 247

guiCamera.setViewportAndMatrices( ) method, 569

guiCam.setViewportAndMatrices( ) method, 460, 463, 465, 487, 604, 606, 624626

guiCam.touchToWorld.touchPoint.set.game.getInput( ) method, 623

image H

hardware-accelerated rendering, with canvas, 191192

hardware, specifications for, 1213

headPixmap.getHeight( ) method, 275

headPixmap.getWidth( ) method, 275

Hello World project, 3338

structure of, 3436

writing application code, 3638

HelloWorldActivity class, 38, 45, 123

help screens, in Super Jumper game, 461463

helpImage.dispose( ) method, 462

HelpScreen class, 251

HelpScreen classes, 251252

hierarchical systems, with matrices, 520526

HierarchicalObject class, 522524

solar system example, 521

HierarchicalObject class, 524, 526

HierarchicalObject.render( ) method, 524

HierarchicalObject.update( ) method, 524

HierarchyScreen.present( ) method, 530

high scores, and user settings, 243245

high-scores screen, 253257, 463466

highJump( ) method, 473, 483

HighscoreScreen class, 255

hit( ) method, 473, 483

hitPlatform( ) method, 472473

hitSpring( ) method, 473

hitSquirrel( ) method, 472473

holder.getSurface( ) method, 189, 232

holder.lockCanvas( ) method, 189, 233

image I

I/O (Input/Output), file, 79

icons, defining for game, 119121

IDEs (Integrated Development Environments), 2533

Eclipse platform

description of, 3032

installing, 2830

shortcuts for, 3233

JDK, 26

image formats, and compression, 9091

inBounds( ) method, 249250

in.close( ) method, 229, 244, 322, 453, 455, 559, 578, 601

indexed vertices, 323329

indices.flip( ) method, 325

indices.limit( ) method, 579

INF file, 39

input devices, 132151

multitouch events, 132, 136143

processing key events, 143146

reading accelerometer state, 146151

reading compass state, 151

single-touch events, processing, 132136

Input interface, 78, 202, 205, 207, 212, 219

Input( ) method, 98

input modules, 7578

Input/Output (I/O), file, 79

Input.getAccelX( ) method, 78

Input.getAccelY( ) method, 78

Input.getAccelZ( ) method, 78

Input.getKeyEvents( ) method, 210

Input.getTouchEvents( ) method, 568

Input.getTouchX( ) method, 78

Input.getTouchY( ) method, 78

Input.isKeyPressed( ) method, 78, 210

Input.isTouchDown( ) method, 78

inputStream.close( ) method, 153, 181

in.readLine( ) method, 244, 453454, 600

insertDynamicObject( ) method, 397

insertStaticObject( ) method, 397

Integer.parseInt.in.readLine( ) method, 244, 453454

Integrated Development Environments. See IDEs

Intent class, 124

Invader class, 611614

invader.kill( ) method, 618

invaders.size( ) method, 616618, 629

invaderTexture.reload( ) method, 599

invalidate( ) method, 169171, 176, 181, 185

isFinishing( ) method, 295

isGameOver( ) method, 619, 623

isKeyPressed( ) method, 210

isLooping( ) method, 83, 201

isPlaying( ) method, 83, 201

isStopped( ) method, 83, 201

isTouchDown( ) method, 215, 218

items.reload( ) method, 452, 599

image J

JAR file, 35

Java class, 8, 33, 122, 124, 129

Java Development Kit (JDK), 26

Java method, 347

Java object, 315

JDK (Java Development Kit), 26

JNI method, 426427

jump( ) method, 473, 483

image K

key events, processing, 143146

KeyboardHandler class, 208

KeyboardHandler handler, 207211

KeyboardHandler.getKeyEvents( ) method, 209, 211, 215

KeyEvent class, 78, 143, 207208, 213

KeyEvent( ) method, 209

KeyEvent type, 210

keyEventPool.newObject( ) method, 209

keyEventsBuffer.clear( ) method, 210

keyEvents.clear( ) method, 210

keyEvents.size( ) method, 210

keyHandler.getKeyEvents( ) method, 221

kill( ) method, 610611, 614, 618

image L

len( ) method, 365, 536537

Level parameter, 41

libraries, system, 89

LifeCycleTest activity, 129, 131

lighting, in OpenGL ES API, 538556

description of, 538540

enabling and disabling, 543

example of, 552556

limitations of, 556

materials, 541, 547548

sources of, 540547

vertex normals, 542552

LightScreen class, 552

line.length( ) method, 254, 257, 276

lines

drawing, 174

in OpenGL ES, 333334

lines.size( ) method, 576

Linux kernel, 7

ListActivity class, 122

ListAdapter interface, 122

listener.coin( ) method, 480

listener.explosion( ) method, 618

listener.highJump( ) method, 480

listener.hit( ) method, 479

listener.jump( ) method, 479

listener.shot( ) method, 616, 619

load( ) method, 159, 162, 244, 321322, 558560, 598, 601

LoadingScreen class

fetching assets from disk with, 246247

fetching from disk with LoadingScreen class, 247

loadTextFile( ) method, 154

loadTexture( ) method, 320

location awareness, 647

locking

SurfaceHolder class and, 187

wake locks, 167

Log class, 129

LogCat system, and DDMS, 4850

logFrame( ) method, 346

logging, LogCat system, 4850

look-at camera, 571572

image M

main activity

for Droid Invaders game, 601602

in Super Jumper game, 454456

main menu screen, 247251

for Droid Invaders game, 602604

in Super Jumper game, 458461

main( ) method, 108

MainMenu class, 238

MainMenu( ) method, 98

MainMenu.update( ) method, 238

manager.getSensorListSensor.TYPE_ACCELEROMETER.size( ) method, 147148, 203

<manifest> element, 109

manifest file, 108121

<activity> element, 111113

<application> element, 110111

<manifest> element, 109

<uses-feature> element, 114116

<uses-permission> element, 113114

<uses-sdk> element, 116

defining game icon, 119121

market filters, 119

steps to set up game project, 117118

market filters, 119

marketing, 645

mass, and force, 372373

Material class, 548

Material( ) method, 553

materials, 541, 547548

Math class, 365

Math.maxhighScores[i].length( ) method, 464

Math.random( ) method, 431

matrices

and 2D transformations, 335336

in 3D, 517530

hierarchical systems with, 520526

matrix stack, 518520

in OpenGL ES, 284285

Matrix class, 534, 537, 562, 584

matrix modes, and active matrices, 298

Matrix.multiplyMV( ) method, 537

Matrix.rotateM( ) method, 537

Matrix.setIdentityM( ) method, 537

MediaPlayer class, 163

MediaPlayer( ) method, 163, 165, 200

mediaPlayer.isLooping( ) method, 201

mediaPlayer.isPlaying( ) method, 164, 200201

mediaPlayer.pause( ) method, 163, 165166, 201

mediaPlayer.prepare( ) method, 163, 165, 200201

mediaPlayer.release( ) method, 164165, 200

mediaPlayer.setDataSourceassetDescriptor.getFileDescriptor( ) method, 200

mediaPlayer.setDataSourcedescriptor.getFileDescriptor( ) method, 163, 165

mediaPlayer.start( ) method, 163166, 200201

mediaPlayer.stop( ) method, 164165, 200, 202

methodFloat.floatToRawIntBits( ) method, 426

minimum target, 1416

mipmapping, 557561

mobile gaming, 2023

big market with small developers, 2223

casual and hardcore gamers, 22

permanent connectivity, 2122

ubiquity of mobile devices, 2021

model space, vs. world space, 334335

Model-View-Controller design pattern. See MVC

models, 573580

limitations of, 579580

OBJ loader, implementing, 574579

Wavefront OBJ format, 573574

MotionEvent class, 136, 143

MotionEvent.ACTION_MASK event, 138

MotionEvent.getAction( ) method, 133, 137138

MotionEvent.getPointerCount( ) method, 138, 141

MotionEvent.getY( ) method, 138

movement

frame-independent, 103104

time-based, in Mr. Nom game, 265266

Mr. Nom game, 239277

abstracting, 257277

GameScreen class, 270277

MVC design pattern, 258269

assets, 239241

HelpScreen classes, 251252

MrNomGame activity, 242247

asset store, 242243

keeping track of user settings and high scores, 243245

LoadingScreen class, 246247

screens

high-scores, 253257

main menu, 247251

setting up project, 241242

MrNomGame activity, 242247

asset store, 242243

keeping track of user settings and high scores, 243245

LoadingScreen class, fetching assets from disk with, 246247

MrNomGame class, 242

MrNomGame.getStartScreen( ) method, 246

mul( ) method, 365, 536

multiplayer functionality, 648

multitouch events

overview, 132

processing, 136143

MotionEvent.ACTION_MASK event, 138

pointer IDs and indices, 137138

in practice, 139143

MultiTouchHandler class, 215219, 236

music

sound and, for Droid Invaders game, 596

streaming, 163166

Music interface, 83, 200

music.play( ) method, 451452, 599

MVC (Model-View-Controller) design pattern, 258269

Snake and SnakePart classes, 260265

Stain class, 260

World class, 265269

ending game, 267

implementing, 267269

placing stains, 266

time-based movement of Mr. Nom, 265266

MyAwesomeGame class, 100

MySuperAwesomeGame class, 102103

MySuperAwesomeGame.getStartScreen( ) method, 102

MySuperAwesomeStartScreen class, 102

MySuperAwesomeStartScreen( ) method, 102

MySuperAwesomeStartScreen.dispose( ) method, 103

MySuperAwesomeStartScreen.pause( ) method, 103

MySuperAwesomeStartScreen.present( ) method, 103

MySuperAwesomeStartScreen.resume( ) method, 103

MySuperAwesomeStartScreen.update( ) method, 103104

image N

narrow phase, collision detection, 385390

circle and rectangle collision, 387389

circle collision, 385386

rectangle collision, 386387

nativeOrder( ) method, 302, 327, 497, 550

newMusic( ) method, 198

newObject( ) method, 206207

newPixmap( ) method, 229

newSound( ) method, 199

nor( ) method, 365, 536537

normalized device space, 284

image O

OBJ file, 574, 578580, 584, 595

OBJ format, Wavefront, 573574

OBJ loader, implementing, 574579

Object( ) method, 292

object representation, and collision detection in 3D programming, 581584

bounding shapes, 581583

GameObject3D and DynamicGameObject3D classes, 583584

ObjLoader.load( ) method, 579

OGG file, 159, 493

onAccuracyChanged( ) method, 149, 204

OnClickListener.onClick( ) method, 38

OnCompletionListener interface, 200201

OnCompletionListener.onCompletion( ) method, 200, 202

onCreate( ) method, 37, 122, 126, 130, 145, 166, 172, 185, 236, 293

onDestroy( ) method, 127128

onDraw( ) method, 169171, 176, 182, 185

onDrawFrame( ) method, 288, 290, 294

onKey( ) method, 143, 145, 210211, 214

OnKeyEventListener.onKeyEvent( ) method, 208

OnKeyListener interface, 145, 208

OnKeyListener.onKey( ) method, 209

onPause( ) method, 126, 128, 162, 166, 188, 236, 288, 293, 295, 602

onRestart( ) method, 126, 128

onResume( ) method, 126, 128, 130, 150, 166, 188, 190, 288, 293, 599

onSensorChanged( ) method, 147, 149, 204

onStop( ) method, 126128

onSurfaceChanged( ) method, 287, 290, 294

onSurfaceCreate( ) method, 293, 455

onSurfaceCreated( ) method, 287288, 290, 602

onTouch( ) method, 133136, 141, 162, 214215, 218

OnTouchListener interface, 132, 134, 136, 141, 161, 212213

open-source programming, Android Open Source Project, 4

OpenGL ES, 279356

2D transformations, 334345

combining of, 343345

and matrices, 335336

rotating, 341342

scaling, 342

using translation, 336341

world space vs. model space, 334335

3D in, 495531

blending, 507510

camera system for, 527530

matrices, 517530

perspective projection, 502504

triangle meshes, 511517

vertices in, 496501

z-buffer, 505507, 510511

z-fighting, 510511

alpha blending, 329333

Android 1.5, 648

API, lighting in, 538556

description of, 538540

enabling and disabling, 543

example of, 552556

limitations of, 556

materials, 541, 547548

sources of, 540547

vertex normals, 542552

colors, specifying for vertices, 309312

defining projection matrix, 298301

matrix modes and active matrices, 298

orthographic projection with glOrthof, 299300

defining viewport, 298

and direct NIO buffers, 302303

fans, 333334

GLGame class, 290297, 306309

GLSurfaceView class, 287290

indexed vertices, 323329

lines, 333334

matrices, 284285

normalized device space, 284

optimizing, 345356

Android 1.5, 347

binding vertices, 352355

frame rate, 345347

possible rendering issues, 347349

reducing calls, 352

reducing texture size, 351352

removing unnecessary state changes, 349351

overview, 279282

points, 333334

primitives, 333334

projections, 282284

rendering pipeline, 285286

strips, 333334

texture mapping, 313322

bitmaps for, 315316

disposing of textures, 317

enabling texturing, 318

Texture class, 321322

texture coordinates, 313315

texture filtering, 316317

triangles with, 302305

optimizing, OpenGL ES, 345356

Android 1.5-347, 347

binding vertices, 352355

frame rate, 345347

possible rendering issues, 347349

reducing calls, 352

reducing texture size, 351352

removing unnecessary state changes, 349351

Options( ) method, 228

orthographic projection, with glOrthof, 299300

out.close( ) method, 245, 454455, 601

overlap testing, bounding sphere, 582583

overlapCircles( ) method, 386

OverlapTester class, 582

image P, Q

Paint class, 174, 177, 184

Paint( ) method, 174, 176, 185, 228

parts.get.parts.size( ) method, 264

parts.size( ) method, 264265

pause( ) method, 83, 101, 250, 257, 277, 307, 462, 488, 516, 626

paused( ) method, 277

perspective projection, 502504

physics, 371378

in 3D programming, 580581

force and mass, 372373

object falling example, 373378

point masses, 371372

pixels

drawing, 173174

rasters, framebuffers and, 8485

Pixmap interface, 96, 226227

Pixmap parameter, 230

Pixmap.dispose( ) method, 97

Pixmap.getFormat( ) method, 96

Pixmap.getHeight( ) method, 96

Pixmap.getWidth( ) method, 96

placeStain( ) method, 268269

Platform class, in Super Jumper game, 469471

Platform int type, 470

platform.pulverize( ) method, 479

platforms.size( ) method, 477, 479

play( ) method, 83, 162, 199, 201

playback, recording and, 8081

PNG file, 182

point lights, 544546

point masses, 371372

pointer IDs, and pointer indices, 137138

pointer indices, 137138

PointLight class, 547

PointLight( ) method, 553, 566

points, in OpenGL ES, 333334

Pool class, 205208

PoolObjectFactory.newObject( ) method, 206

PowerManager.FULL_WAKE_LOCK type, 167

PowerManager.newWakeLock( ) method, 167

precision, of z-buffer, 510511

preferences, shared, 158

present( ) method, 233, 250, 320, 349, 403, 424, 517, 569, 620, 625

presentGameOver( ) method, 487488, 624, 626

presentLevelEnd( ) method, 487488

presentPaused( ) method, 487488, 624625

presentReady( ) method, 487

presentRunning( ) method, 487, 624626

primitives, in OpenGL ES, 333334

Product Details section, 644

programming

audio, 7983, 158159

audio quality and compression, 8182

physics of sound, 80

in practice, 8283

recording and playback, 8081

setting volume controls, 158159

core game mechanics, 6466

file I/O, 79

game framework, 97104

example of, 102103

frame-independent movement, 103104

game and screen interfaces, 99101

graphics, 8497, 167192

alpha compositing and blending, 9194

bitmaps, 178183

colors, 8790

continuous rendering in UI thread, 169172

drawing shapes, 173177

going full-screen, 168169

image formats and compression, 9091

in practice, 9497

rasters, pixels, and framebuffers, 8485

rendering, 183186, 192

screen resolution and coordinate systems, 172173

vsync and double-buffering, 8687

wake locks, 167

modules

application and window management, 74

input, 7578

projection matrix, defining in OpenGL ES, 298301

matrix modes and active matrices, 298

orthographic projection with glOrthof, 299300

projections, in OpenGL ES, 282284

Publish button, 645

publishing, 635646

becoming registered developer, 636637

developer console, 645646

putting game on Android Market website, 642645

marketing, 645

Product Details section, 644

Publish button, 645

Publishing Options panel, 644645

uploading assets, 643644

signing APK file, 637641

testing applications, 635636

Publishing Options panel, 644645

pulverize( ) method, 471

put( ) method, 303, 309

puzzle games, 5657

image R

rand.nextFloat( ) method, 289, 297, 337, 475, 479

Random class, 171, 267

Random( ) method, 171, 267, 289, 297, 337, 474, 615

Random.nextFloat( ) method, 476

rasters, pixels, 8485

reader.close( ) method, 156

reader.readLine( ) method, 156, 578

readLines( ) method, 575, 578

recording, and playback, 8081

Rect class, 180

Rect( ) method, 181, 185, 228, 232

Rectangle class, 583

rectangles

collision of, 386387

drawing, 174175

registered developers, becoming, 636637

reload( ) method, 322, 452, 560, 599

removeObject( ) method, 397

render( ) method, 340, 487, 489490, 523, 526, 607, 625, 628, 632

renderBackground( ) method, 489490

renderBob( ) method, 490491

renderCastle( ) method, 490, 492

renderer.render( ) method, 487

rendering

continuous

with SurfaceView class, 186192

in UI thread, 169172

hardware-accelerated, with canvas, 191192

text, 183186

alignment and boundaries of, 184

fonts, 183184

putting it all together, 184186

renderItems( ) method, 490492

renderObjects( ) method, 489490

renderPlatforms( ) method, 490491

renderSquirrels( ) method, 490, 492

renderThread.join( ) method, 189, 233

renderThread.start( ) method, 189, 232

RenderView class, 171172, 182, 189

renderView.pause( ) method, 188, 236

renderView.resume( ) method, 188, 236

RenderViewTest activity, 171

resolutions, screen sizes and, 221226

resume( ) method, 101102, 247, 251, 350, 354, 377, 465, 500, 626

rotate( ) method, 366, 422, 535, 537, 564

rotating, 2D transformations, 341342

run( ) method, 189190, 232233

Runnable interface, 190

runtime, and Dalvik VM, 78

image S

save( ) method, 245, 605

scaling, 2D transformations, 342

score.length( ) method, 274

scores, high, and user settings, 243245

scoreString.length( ) method, 488

Screen class, 99100, 246, 308

Screen interface, 238

screen interface, game interface and, 99101

screen resolution, and coordinate systems, 172173

screen sizes, and resolutions, 221226

Screen.dispose( ) method, 101, 236, 294

Screen.pause( ) method, 101, 236, 294

Screen.present( ) method, 101, 231

Screen.render( ) method, 288

Screen.resume( ) method, 101, 236237, 293, 296

screens

high-scores, 253257

main menu, 247251

in Super Jumper game, 437438

game screen, 481489

help screens, 461463

high-scores screen, 463466

main menu screen, 458461

and transitions, 6772, 590

Screen.update( ) method, 101, 231, 266

SDKs (software development kits), 1011

SensorEventListener interface, 149, 203

SensorManager class, 151

SensorManager.getRotationMatrix( ) method, 151

setAngles( ) method, 563564

setDirection( ) method, 547

setFilters( ) method, 322

setIndices( ) method, 327, 550

setLooping( ) method, 202

setMatrices( ) method, 564, 572, 629

setPosition( ) method, 547

setScreen( ) method, 237238

Settings class

for Droid Invaders game, 600601

in Super Jumper game, 453454

settings screen, for Droid Invaders game, 604607

Settings.loadgame.getFileIO( ) method, 246

Settings.loadgetFileIO( ) method, 602

Settings.load( ) method, 247

Settings.savegame.getFileIO( ) method, 250, 276, 460, 485, 606

setVertices( ) method, 327, 498, 500, 550

setViewportAndMatrices( ) method, 408409

shapes, drawing, 173177

circles, 175

demonstration of, 175177

lines, 174

pixels, 173174

rectangles, 174175

shared preferences, 158

Shield class, 608

shields.size( ) method, 618, 630

Ship class, 609611, 614

ship.kill( ) method, 617618

shipTexture.reload( ) method, 599

shoot( ) method, 619

shortBuffer.flip( ) method, 323

Shot class, 608609

shot( ) method, 614, 621

shots.size( ) method, 617619, 631

SimpleRenderer( ) method, 289

simulation classes, 607619

Invader, 611614

Shield, 608

Ship, 609611

Shot, 608609

World, 614619

single-touch events, processing, 132136

SingleTouchHandler class, 212215

SingleTouchHandler.getTouchEvents( ) method, 215, 219

SingleTouchHandler.onTouch( ) method, 218

Snake class, and SnakePart class, 260265

Snake( ) method, 263, 268

snake.advance( ) method, 266, 268

snake.eat( ) method, 269

SnakePart class, Snake class and, 260265

snake.parts.size( ) method, 268269, 275

social media, integration with, 647

software development kits (SDKs), 1011

solar system example, 521

sound

effects, playing, 159162

and music, for Droid Invaders game, 596

physics of, 80

in Super Jumper game, 448449

Sound interface, 8283, 199

SoundPool class, 162, 166

SoundPool.load( ) method, 159160, 162

SparseArray class, 192

SpatialHashGrid class, 400, 481

SpatialHashGrid.getCellIds( ) method, 396, 398

SpatialHashGrid.getPotentialColliders( ) method, 403

Sphere class, 582583

Spring class, in Super Jumper game, 466467

springs.size( ) method, 480

Sprite class, 418

SpriteBatcher class, 423, 428, 595

SpriteBatcher method, 425426

SpriteBatcher.beginBatch( ) method, 419

SpriteBatcher.drawSprite( ) method, 418419, 422, 446

SpriteBatcher.endBatch( ) method, 419

sprites

animating, 427433

Animation class, 428429

example of, 429433

SpriteBatcher class, 418427

measuring performance of, 425426

using, 423425

working around bug in FloatBuffer, 426427

SQLite database, 154

Squirrel class, in Super Jumper game, 468469

squirrels.size( ) method, 478479

Squirrel.update( ) method, 471

Stain class, 260261

stains, placing, 266

state changes, removing unnecessary, 349351

stateChanged.notifyAll( ) method, 294

stateChanged.wait( ) method, 295

staticCells[cellId].size( ) method, 398

stop( ) method, 83, 164, 200, 202

storage, external, accessing, 154157

stories, and art style, 6667

String file, 79, 82, 196, 198, 319, 321, 454, 558, 575, 600

StringBuilder( ) method, 129, 133, 139, 144, 148, 156

String.byteStream.toByteArray( ) method, 153

strips, in OpenGL ES, 333334

sub( ) method, 365, 536

sun.update( ) method, 530

Super Jumper game, 435494

art style for, 436437

Assets class, 450452

assets in, 441449

game elements, 445447

sounds, 448449

text with bitmap fonts, 443445

texture atlas, 447

UI elements, 441442

benchmarking, 492493

Bob class, 471473

Castle class, 468

Coin class, 467468

Font class, 456457

game screen, 481489

rendering, 486488

updating, 483486

game world of, 438441

GLScreen, 457458

help screens, 461463

high-scores screen, 463466

main activity, 454456

main menu screen, 458461

overview, 435436

Platform class, 469471

screens in, 437438

Settings class, 453454

Spring class, 466467

Squirrel class, 468469

World class, 473481

collision detection in, 478480

game over state, 481

generating world, 475476

updating world, 477478

WorldRenderer class, 489492

SuperJumper class, 462

SuperJumper.getStartScreen( ) method, 458

super.onPause( ) method, 130, 165, 188, 236, 289, 295, 602

super.onResume( ) method, 130, 165, 188, 236, 293

SurfaceHolder class, and locking, 187

surfaceHolder.getSurface( ) method, 187

SurfaceHolder.lockCanvas( ) method, 187188

surfaces, checking validity of, 187188

SurfaceView class, 186192, 231, 287

checking surface validity, 187188

demonstration of, 188191

reason for using, 187

SurfaceHolder class and locking, 187

surfaceView.getHolder( ) method, 187

system libraries, 89

System.nanoTime( ) method, 232233, 292294, 346, 615, 619

image T

targets.size( ) method, 403, 414, 424

targetVertices.bind( ) method, 403, 414

targetVertices.unbind( ) method, 403, 414

test activities, 124125

text, 183186

alignment and boundaries of, 184

with bitmap fonts, in Super Jumper game, 443445

fonts

drawing text with, 183184

loading, 183

putting it all together, 184186

text.length( ) method, 185, 457

text.toString( ) method, 156

texture atlas

overview, 410416

in Super Jumper game, 447

Texture class, 325, 329, 331, 558, 584

texture mapping, 313322

bitmaps for, 315316

disposing of textures, 317

enabling texturing, 318

optimizing, reducing size of, 351352

Texture class, 321322

texture coordinates, 313315

texture filtering, 316317

texture.bind( ) method, 325, 414, 421, 514, 516, 525, 555

TexturedTriangleScreen class, 318

TextureRegion class, 417418

texture.reload( ) method, 349, 516, 553

textureRgba.bind( ) method, 331

textureRgb.bind( ) method, 331

textView.requestFocus( ) method, 144

textView.setTextbuilder.toString( ) method, 130, 139, 149

this.indices.clear( ) method, 327, 497, 550

this.indices.flip( ) method, 327, 497, 550

this.position.set(float)Math.random( ) method, 430

this.screen.dispose( ) method, 237, 296

this.screen.pause( ) method, 237, 296

this.velocity.set.Math.random( ) method, 430

this.vertices.clear( ) method, 327, 426, 497, 550

this.vertices.flip( ) method, 327, 426, 497, 550

time-based movement, in Mr. Nom game, 265266

toFloatBuffer.put( ) method, 303

topText.length( ) method, 488

touch handlers, 211219

MultiTouchHandler class, 215219

SingleTouchHandler class, 212215

TouchHandler interface, 212

TouchEvent class, 78, 212

TouchEvent( ) method, 207, 213, 216

touchEventPool.newObject( ) method, 207, 214, 216217

touchEventsBuffer.clear( ) method, 215, 218219

touchEvents.clear( ) method, 215, 218

touchEvents.size( ) method, 215, 218, 249, 256, 273, 369, 402, 462, 484, 486

TouchHandler interface, 212213

touchHandler.getTouchEvents( ) method, 220

touchPos.len( ) method, 376, 402

touchPos.sub(cannonPos).angle( ) method, 369, 376

touchPos.sub(cannon.position).angle( ) method, 402

TouchTest activity, 168

TouchTest class, 168169

touchToWorld( ) method, 409

tower-defense games, 61

transitions, screens and, 6772, 590

triangle meshes, 3D in OpenGL ES, 511517

triangles, with OpenGL ES, 302305

trigonometry, for vectors, 361362

turnLeft( ) method, 263264

turnRight( ) method, 263264

Typeface class, 186

Typeface.createFromAsset.context.getAssets( ) method, 183, 185

image U

UI (User Interface)

assets, for Droid Invaders game, 593594

thread, continuous rendering in, 169172

unbind( ) method, 354, 498, 551552

update( ) method, 238, 339, 369, 410, 471, 478, 523, 610, 615, 617

updateBob( ) method, 477, 481

updateCoins( ) method, 478

updateGameOver( ) method, 274, 484, 486, 622, 624

updateLevelEnd( ) method, 484, 486

updatePaused( ) method, 273, 484486, 622623

updatePlatforms( ) method, 478479

updateReady( ) method, 272, 484

updateRunning( ) method, 273, 485, 488, 623

updateSquirrels( ) method, 478

updateTextView( ) method, 139140

USB driver, 26

user experience, designing, 6372

core game mechanics, 6466

screens and transitions, 6772

story and art style, 6667

User Interface. See UI

user settings, and high scores, keeping track of, 243245

<uses-feature> element, 114116

<uses-permission> element, 113114

<uses-sdk> element, 116

image V

vectors, 358371

in 3D programming, 534538

overview, 359361

triangle cannon example, 366371

trigonometry for, 361362

Vector class, 363366

velocity.len( ) method, 373374

vertex normals, 542, 549552

Vertical Synchronization (vsync), and double-buffering, 8687

vertices

in 3D, 496501

colors for vertices, 309312

Vertices class, 326330, 353, 355, 357, 426, 495496

Vertices3 class, 496498

Vertices.bind( ) method, 354355, 369, 421, 500, 504, 506, 508

vertices.draw( ) method, 331, 335, 353354, 509

vertices.flip( ) method, 303, 306, 309, 311, 314, 319, 324325

vertices.limit( ) method, 579

vertices.position( ) method, 498

Vertices.setVertices( ) method, 426

Vertices.unbind( ) method, 354, 369, 421, 500, 504, 506, 508

View class, 169, 171, 189190

viewport, defining in OpenGL ES, 298

View.requestFocus( ) method, 144, 209

virtual devices, AVDs, 3940

volume controls, setting, 158159

vsync (Vertical Synchronization), and double-buffering, 8687

image W

wake locks, 167

WakeLock class, 167

wakeLock.acquire( ) method, 167, 236, 293

wakeLock.release( ) method, 167, 236, 295

Wavefront OBJ format, 573574

web resources, 650651

windowMgr.getDefaultDisplay( ) method, 150

World class, 265269, 614619

ending game, 267

implementing, 267269

placing stains, 266

in Super Jumper game, 473481

collision detection in, 478480

game over state, 481

generating world, 475476

updating world, 477478

time-based movement of Mr. Nom, 265266

World( ) method, 268, 272, 615, 621

world space, vs. model space, 334335

world.coins.size( ) method, 491

WorldListener interface, 614

WorldListener( ) method, 483, 621

WorldListener.jump( ) method, 479

world.platforms.size( ) method, 491

WorldRender class, 626631

WorldRenderer class, 482, 487, 489492, 609

world.shot( ) method, 623

world.snake.turnLeft( ) method, 272

world.snake.turnRight( ) method, 272

world.springs.size( ) method, 491

world.squirrels.size( ) method, 492

World.update( ) method, 478, 481, 620

writer.close( ) method, 156

image X, Y

XML file, 110

image Z

z-buffer, 3D in OpenGL ES, 505511

z-fighting, 3D in OpenGL ES, 510511

ZBlendingScreen class, 508

ZBufferScreen class, 506

ZIP file, 28

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

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