Tải bản đầy đủ (.pdf) (402 trang)

monkey game development beginner's guide [electronic resource] create monetized 2d games deployable to almost any platform

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.5 MB, 402 trang )

Monkey Game Development
Beginner's Guide
Create monezed 2D games deployable to almost
any plaorm
Michael Hartlef
BIRMINGHAM - MUMBAI
Monkey Game Development
Beginner's Guide
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmied in any form or by any means, without the prior wrien permission of the
publisher, except in the case of brief quotaons embedded in crical arcles or reviews.
Every eort has been made in the preparaon of this book to ensure the accuracy of the
informaon presented. However, the informaon contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark informaon about all of the
companies and products menoned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this informaon.
First published: April 2012
Producon Reference: 1130412
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-203-8
www.packtpub.com
Cover Image by J.Blaminsky ()
Credits


Author
Michael Hartlef
Reviewers
Nikolas Kolm
Meri Morganov
Acquision Editor
Karkey Pandey
Lead Technical Editor
Shreerang Deshpande
Technical Editors
Apoorva Bolar
Arun Nadar
Priyanka S
Copy Editor
Brandt D'Mello
Project Coordinator
Alka Nayak
Proofreader
Aaron Nash
Indexer
Hemangini Bari
Graphics
Manu Joseph
Producon Coordinator
Melwyn D'Sa
Cover Work
Melwyn D'Sa
About the Author
Michael Hartlef has been into game development for a long long me, starng in 1984,
at the early age of 18, with this great hobby called developing computer games, on the

Commodore C64. Aer developing for this machine, he has worked on most other well-known
computers, such as the Amiga 1000 and 500, the Atari 1024 STFm, and of course various PCs.
These days it is mostly his iMac that he uses.
Over the years, he has become very knowledgeable about general and specic concepts
for developing games and has worked on a large range of game development tools/
programming languages, such as thinBasic, Delphi, 3D GameStudio, Blitz3D, BlitzMax,
DarkBasic Pro, App Game Kit (AGK), Corona SDK, and of course, Monkey! Besides working on
games, Michael has developed various add-ons for tools such as command library extensions
and programming editors.
During the day, Michael works for a ulity company where he maintains the billing system
(SAP IS-U). Michael is also the founder of an independent game developer startup called
Whitesky Games (
). There, he spends a lot of his spare
me working on game development tools (IndeED), add-ons and games for friends and
clients, and his own projects.
First, I'd like to thank my wonderful wife Katherine and my great son Marc
Jusn for having so much paence with me during the me of wring this
book and giving me all the support I needed. Without you guys, I would not
have made it. I love you!

Also, I would like to thank the people at PacktPub for giving me the
opportunity to write this book, which has been a great experience in my
life. Next, I send a big thank you to Jayant Varma from Oz Apps, who hinted
to me that PacktPub was looking for an author for this book. Also, I want to
thank Lee Bardsley from GameLab3D for being my friend and talk buddy.

And nally, a big thank you goes to Mark Sibly, the creator of Monkey, for
providing such an awesome tool for the people and me.
About the Reviewers
Nikolas Kolm has been acve as a Level Designer, World Builder, and Interacve Storyteller

for a long me, in capacies ranging from community Mod projects, to student work, to
indie producon. During this me, he has gathered a lot of experience in dierent editors
and producon sengs, most commonly the Unreal Editor, the NWN2 Toolset, and the
Dragon Age Toolset as well as Game Maker, and recently, Unity 3D.
During his me along with the Mod team responsible for a persistent world server for
Neverwinter Nights 2, Nikolas was responsible for the creaon of interesng areas and levels
for players to traverse and live in, which needed to adhere to a common theme with the rest
of the world, and also had to oer challenges for groups of players out for an adventure.
This included seng up encounters with enemies, seng up the ambient eects, creang
dialogue for scripted encounters, and ensuring that the area supported the environmental
storytelling of the module.
While working on the indie tle AVOID, as Lead Game Designer, Niko also had to ll in as
Level Designer from me to me, which allowed him to pracce his skills with the Unity
editor. It also allowed him to work in a leadership capacity with a team of over 30 other
team members, to experience a complete producon cycle.
His unique background, living in Japan, traveling the world, and studying many cultures and
history, has given him a wealth of experience from which to draw when designing believable
characters, dramac encounters, and immersive worlds.
Meri Morganov has been playing video games for most of her life and has always
wondered what the magic behind them was. She took game programming courses at the
Art Instute of Vancouver to learn more on the topic and worked with big student groups to
make games. From high-level scripng to low-level programming, she worked hard to learn
the art of the trade.
Aer college she has been working on indie projects with friends and small companies. She
loves working in teams and staying in close contact with her teammates to get the job done
right. Unity3D and Visual Studio have been her favorite tools to use.
I'd like to thank my teachers and friends who made it possible for me to
learn such a great skill.
www.PacktPub.com
Support les, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support les and downloads related to
your book.
Did you know that Packt oers eBook versions of every book published, with PDF and ePub
les available? You can upgrade to the eBook version at
www.PacktPub.com and as a print
book customer, you are entled to a discount on the eBook copy. Get in touch with us at
for more details.
At
www.PacktPub.com, you can also read a collecon of free technical arcles, sign up for
a range of free newsleers and receive exclusive discounts and oers on Packt books and
eBooks.

Do you need instant soluons to your IT quesons? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's enre library of books.
Why Subscribe?
 Fully searchable across every book published by Packt
 Copy and paste, print and bookmark content
 On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine enrely free books. Simply use your login credenals for
immediate access.

Table of Contents
Preface 1
Chapter 1: Monkey—Huh? 7
Game development for the rest of us 8
Cross-plaorm development 8
Compiler or translator? 8
The Monkey toolbox 9

Time for acon – installing Monkey 10
Please welcome… Monk 10
MSERVER—Monkey's own web server 11
Let's have a lile playme 12
Time for acon – playing Pirate TriPeaks 12
Time for acon – playing Surviball 14
Playing to have fun, playing to study 15
So let's go for something big? No! 15
The alternave 15
Time for acon – read the manual 16
The Trans tool and the supported target plaorms 16
HTML5 16
FLASH 17
iOS 17
Android 17
XNA 17
GLFW 18
The Monkey standard modules 18
Lang 18
Lists 18
Map 19
Math 20
Random 21
Set 21
Stack 22
Table of Contents
[ ii ]
Mojo – The 2D framework/modules 22
App 23
Audio 23

Graphics 23
Input 23
Monkey is extendable 23
Your own modules 23
Nave source code 23
Third-party modules 24
Your own targets 24
Your game is easily portable 24
Summary 25
Chapter 2: Geng to Know your Monkey—a Trip to the Zoo 27
Call the Monk and start praying—the Monkey IDE 28
Why learn about Monk? 28
Starng up Monk 28
Monk's user interface 29
The toolbar 29
The code editor area 29
The info box 29
Time for acon – opening a sample script 30
Where is my navi? 31
Time for acon – navigang to the Main() funcon 32
Save save save! 32
Time for acon – saving a script 32
Projects—bringing in some organizaon 33
Time for acon – creang a project 33
The Monkey programming language 34
Time for acon – Monkey's Hello World 34
Running your rst script in a browser 35
Our rst lile game PONGO 36
Time for acon – the basic structure of your game 36
Pongo's data structure 38

Time for acon – adding some data elds 38
Time for acon – rendering the game eld 39
Time for acon – drawing the ball and the paddles 40
Time for acon – player paddle movement 41
Time for acon – moving the enemy paddles 42
Time for acon – moving the ball 43
Time for acon – controlling the ball with the player's paddle 45
Time for acon – leng the enemy paddles ght back 46
Time for acon – acng on the dierent game modes 48
Table of Contents
[ iii ]
Exporng your game as an HTML5 website 51
One more thing comment your code! 51
Summary 52
Chapter 3: Game #2, Rocket Commander 53
The game objects 54
The basic le structure 55
Time for acon – building the basic le structure of the game 55
Hold that data—RocketCommander's data structure 58
Time for acon – creang the general data structure of the game 58
Detailing the Update process 59
Time for acon – detailing the Update process 59
Detailing the Render process 60
Time for acon – detailing the Render event 60
Enhancing the OnCreate event 62
Time for acon – detailing the OnCreate process 62
Let's build some cies 63
Time for acon – building some cies 63
Implemenng the city class into the game 66
Time for acon – changing the gameClasses le 66

Modifying the RocketCommander class 66
Time for acon – spawning some cies in the game 67
Rendering the ground and the cies 67
Time for acon – rendering the cies 67
Get the launchers ready! 68
Time for acon – implemenng the rocket launchers 68
Implemenng the launcher class into the game 72
Time for acon – changing the gameClasses le again 73
Modifying the RocketCommander class 73
Time for acon – creang some launchers in the game 73
Updang the rocket launchers 74
Time for acon – updang the launchers 74
Enhancing the UpdateMenu method 74
Time for acon – modifying the menu update process 74
Rendering our precious rocket launchers 75
Time for acon – rendering the launchers 75
Fire! Blast them to pieces! 76
Time for acon – implemenng some rockets 76
Implemenng the rocket class into the game 80
Time for acon – modifying the gameClasses le 80
Modifying the launcher class 80
Table of Contents
[ iv ]
Time for acon – modifying the launcher class 81
Updang the rockets 81
Time for acon – updang the rockets 81
Rendering our furious rockets 81
Time for acon – rendering the rockets 82
And it goes BOOM! Explosions 82
Time for acon – implemenng explosions 82

Implemenng the explosion class into the game 84
Time for acon – modifying the gameClasses le 84
Modifying the rocket class 85
Time for acon – modifying the rocket class 85
Updang the explosions 85
Time for acon – updang the explosions 85
Rendering beauful explosions 86
Time for acon – rendering the explosions 86
Don't fear the enemy—bombs 86
Time for acon – creang the bomb class 86
Implemenng the bomb class into the game 91
Time for acon – modifying the gameClasses le 91
Updang bombs 91
Time for acon – updang the bombs 92
Rendering beauful bombs 92
Time for acon – rendering the bombs 92
Creang new bombs and checking for GameOver condions, or new level
condions 93
Time for acon – modifying the UpdateGame method 93
Displaying the game score 94
Time for acon – displaying the game score 94
Summary 95
Chapter 4: Game #3, CometCrusher 97
Using a game framework—the fantomEngine 98
Game resources 98
Images 99
Sounds 99
Bitmap fonts 100
The game objects 100
Layers 101

Background stars 101
Comets 101
The player ship 102
Table of Contents
[ v ]
The shield 103
Shots 103
Parcles 104
Game info text 104
The basic le structure 104
Time for acon – create the main source le and its folders 104
Open the storage please—the data structure of CometCrusher 107
Time for acon – creang the data structure 107
First changes to the OnCreate method 109
Time for acon – modifying the OnCreate method 109
Detailing the Render process 110
Time for acon – detailing the OnRender method 110
This is a setup—creang the game objects 110
Group yourself—layers 110
Time for acon – creang some layers 111
Let them shine—the background stars 111
Time for acon – implemenng some stars 111
The Hero—creang the player ship 112
Time for acon – seng up the player ship 112
Did you hear that—loading sounds 114
Time for acon – creang a method to load sounds 114
Did you see that score—the game UI 115
Time for acon – creang some game info text objects 115
Headlines—adding a tle screen 116
Time for acon – adding a tle screen 116

How good are you—the high score list 117
Time for acon – seng up the high score list 117
Rocks rocks rocks—ll the space with some comets 118
Time for acon – create a comet 118
Time for acon – creang some comets 119
Mission complete nalizing the OnCreate process 120
Time for acon – nalizing the OnCreate method 120
We need help—more methods for the Update process 121
Loading and showing the high score list 121
Time for acon – loading a high score list 122
Time for acon – showing the high score list 122
Acvang the shield of the player ship 123
Time for acon – the AcvateShield method 123
Delta me related movement 124
Time for acon – determine the me delta 124
Updang the game stasc info text objects 124
Table of Contents
[ vi ]
Time for acon – updang the info text 125
Starng a new game 125
Time for acon – creang a StartNewGame method 125
Let the engine glow 126
Time for acon – spawning some engine parcle FX 126
And it goes boom—creang an explosion 127
Time for acon – creang some explosions 127
Give me that gun—spawning a shot 128
Time for acon – spawning some shots 128
Save some high scores, will ya! 129
Time for acon – saving the high score list 129
Finalizing the OnUpdate method 130

Time for acon – nalizing the OnUpdate method 130
Bring in the acon—shaping the engine class 132
Crack these objects—object collision handling 132
Time for acon – detailing the collision detecon 132
It's about me—acng on mer events 134
Time for acon – detailing the OnObjectTimer method 134
Everything is under control—object update events 135
Time for acon – detailing the OnObjectUpdate method 135
Did I win—checking the losing condions with OnLayerUpdate 136
Time for acon – detailing the OnLayerUpdate method 136
One last thing—creang a FLASH game 138
Summary 139
Chapter 5: Game #4, Chain Reacon 141
Modifying the HTML5 canvas size 142
Time for acon – modifying canvas size 142
Some development basics 142
Frameworks/modules 143
Sprite sheets 143
Content scaling 144
Touch input 144
Suspend and Resume events 144
Animaon 145
Game resources 146
Game objects 146
Layers 146
Title screen 146
Game background 147
Atom les 147
Table of Contents
[ vii ]

Game info text 147
The basic app structure 147
Time for acon – creang the main source le and its folders 147
The data storage 150
Time for acon – creang the data structure 150
First changes to the OnCreate event 152
Time for acon – rst changes to the OnCreate method 152
Detailing the OnRender event 153
Time for acon – detailing the OnRender method 153
Seng up the game objects 154
Sound eects 154
Time for acon – loading the game sound eects 154
Game layers 154
Time for acon – creang layers for the game 154
Game screen 155
Click here – Adding buons 155
Time for acon – creang buons 155
The info text objects 156
Time for acon – creang info text objects 156
The actual game screen 157
Time for acon – composing the game screen 157
Title screen 158
Time for acon – creang the tle screen 158
Finalizing the OnCreate event 159
Time for acon – nalizing the OnCreate method 159
Helper funcons for the update process 159
Creang the atom elements 159
Collision circle objects 160
Time for acon – creang collision circles 160
Atom elements 160

Time for acon – creang the atom elements 161
Starng a new game 163
Time for acon – creang a StartNewGame method 163
Time-related movement 164
Time for acon – implemenng the GetDeltaTime method 164
Updang the info text objects 165
Time for acon – creang a method to update the text informaon 165
Detailing the OnUpdate event 165
Time for acon – nalizing the OnUpdate method 166
Introducing the OnSuspend event 167
Time for acon – modifying the OnSuspend event 167
Table of Contents
[ viii ]
Introducing the OnResume event 168
Time for acon – updang the OnResume method 168
The heart of the game - the engine class 169
What are transions? 169
Touch me – acng on touch hits 169
Time for acon – enhancing the OnObjectTouch method 169
The eagle has landed—a transion is nished 171
Time for acon – detailing the OnObjectTransion method 171
It's about me—mer events 171
Time for acon – acng on mer events 172
Captain! Collision ahead!—doing collision checks 172
Time for acon – detailing the collision detecon 173
Creang an Android app 174
Changing icons 174
Do a name change 175
Signing an applicaon for the market 175
Summary 175

Chapter 6: Game #5, Balls Out! 177
Which frameworks and modules are used? 178
Game resources 178
Our lovely game objects 179
Layers 179
The tle screen 179
Game background 180
The ball 180
Enemies 180
The ball les 180
The basic app structure 180
Time for acon – creang the basic le structure 180
Modifying the HTML5 canvas size for tesng 181
Time for acon – modifying the HTML5 output 181
The data storage 182
Time for acon – creang the data structure 182
First changes to the OnCreate event 184
Time for acon – rst changes to the OnCreate method 184
Detailing the OnRender event 185
Time for acon – detailing the OnRender method 185
Seng up the game objects 185
Make some noise—sound eects 186
Time for acon – loading the game sound eects 186
Table of Contents
[ ix ]
Lay your head on me—the game layers 186
Time for acon – creang layers for the game 186
Our beloved play eld—the background screen 187
Buons—I need more text buons! 187
Time for acon – creang text buons 187

The background screen as usual 188
Time for acon – composing the game screen 188
Give it a name—the tle screen 189
Time for acon – creang the tle screen 189
Finalizing the OnCreate event 190
Time for acon – nalizing the OnCreate method 190
Helper methods for the update process 191
Creang the les 191
Time for acon – creang the les 191
The main actor—creang the ball 193
Time for acon – creang the ball 193
The bad guys—our beloved enemies 194
Time for acon – creang the enemy class 194
More helper funcons 197
Spawning an enemy 197
Time for acon – spawning an enemy 197
Starng a new game 197
Time for acon – creang a StartNewGame method 198
Bring me up-to-date—detailing the OnUpdate event 199
Time for acon – detailing the OnUpdate method 199
Eye candy—parcle eects 200
The parcle emier class 201
Time for acon – creang the parcle emier class 201
The last helper method 203
Time for acon – spawning a parcle emier 203
The heart of the game—the engine class 204
Touch me—acng on touch hits 204
Time for acon – enhancing the OnObjectTouch method 204
Controlling the ball—acng on object update events 205
Time for acon – acng on object update events 205

What's the situaon? Layer update events 207
Time for acon – acng on layer update events 207
We reached our parking posion—a transion is done 209
Time for acon – detailing the OnObjectTransion method 209
Bump bump—checking for collisions 210
Time for acon – detailing the collision detecon 210
Table of Contents
[ x ]
Creang an iOS app 212
Summary 213
Chapter 7: Game #6, At The Docks 215
Frameworks and modules used 216
Game resources 216
The game objects 216
Layers 216
The default layer 217
The tle screen 217
Game screen 217
Wall les 217
Floor les 217
Target les 217
Crate les 218
The player machine 218
The basic app structure 218
Time for acon – creang the basic le structure 218
Modifying the HTML5 canvas size for tesng 219
Time for acon – modifying the HTML5 output 219
The storage for our data 219
Time for acon – creang the data structure 220
Seng up the game objects 222

Slice over slice—game layers 222
Time for acon – creang layers for the game 222
The second-most important part—a tle screen 222
Time for acon – creang the tle screen 223
Detailing the OnCreate event 224
Time for acon – nalizing the OnCreate method 224
Some exible methods for the update process 225
Lads and gents… the main actor 226
Time for acon – creang the player 226
The level maps—loading the les 227
Time for acon – loading the level les 228
On your marks—starng a new game 233
Time for acon – creang a StartNewGame method 233
Bring me up-to-date—detailing the OnUpdate event 233
Time for acon – detailing the OnUpdate method 234
And acon!—the engine class 236
Move it… object updates 236
Time for acon – updang each object 236
Table of Contents
[ xi ]
Push push—checking for collisions 238
Time for acon – detailing collision detecon 238
I can't see it anymore—the transion is nished! 239
Time for acon – detailing the OnLayerTransion method 240
Creang a XNA app 241
Summary 241
Chapter 8: Game #7, Air Dogs 1942 243
Frameworks and modules used 244
No silver, no gold, but… our game resources! 244
The game objects 244

Layers 244
The tle screen 245
Game background 245
The player plane 246
The enemy plane 246
Bullets 246
Clouds 246
Info text 247
Smoke parcles 247
Explosions 247
The basic app structure 247
Time for acon – seng up the basic le structure 248
Storing data 248
Time for acon – creang the data structure 248
First changes to the OnCreate event 250
Time for acon – rst changes to the OnCreate method 251
Seng up the game objects 251
Making some noise… sound eects! 251
Time for acon – loading the game sound eects 252
Lay your head on me… the game layers 252
Time for acon – creang layers for the game 252
Over high ground—the background screen 253
Time for acon – composing the background screen 253
Hope it won't rain—creang the clouds 254
Time for acon – creang the clouds 254
What is going on?—creang info text objects 255
Time for acon – creang info text objects 256
What are we playing here?—The tle/menu screen 256
Time for acon – creang the tle screen 257
Finalizing the OnCreate event 258

Table of Contents
[ xii ]
Time for acon – nalizing the OnCreate method 258
Methods for the update process 259
The hero—spawning the player plane 259
Time for acon – spawning the player plane 259
Spawning an enemy 260
Time for acon – spawning an enemy plane 260
Starng a new game 261
Time for acon – creang a StartNewGame method 261
Detailing the OnUpdate event 262
Time for acon – detailing the OnUpdate method 263
Making it look nicer—some parcle eects 265
Eming smoke 265
Time for acon – eming the smoke 265
Boom!—Eming explosions 266
Time for acon – creang the explosion 267
Pow!—spawning a shot 268
Time for acon – spawning a shot 268
The brain—Computer AI (Arcial Intelligence) 270
Follow him!—creang a brain for the enemy pilot 270
Time for acon – following the player 270
The heart of the game—the engine class 271
Time management—acng on object mer events 271
Time for acon – enhancing the OnObjectTimer method 271
It is gone!—a transion is done 272
Time for acon – detailing the OnObjectTransion method 272
Controlling the player plane—acng on object update events 272
Time for acon – acng on object update events 272
Hit it!—handling collision response 274

Time for acon – detailing the collision response 274
Did I win?—layer update events 276
Time for acon – acng of layer update events 276
Creang a GLFW app 278
Summary 278
Chapter 9: Game #8, Treasure Chest 279
Frameworks and modules used 280
Reusing code 280
The parts of the game resources 280
And here they are… the game objects! 281
Layers 281
Our precious tle screen 282
Table of Contents
[ xiii ]
A menu screen 282
The "high-score" screen 282
A game background 283
The worthy gems 283
The gem selector 284
Parcle eects 284
Preparaon… the basic app and project structure 284
Time for acon – creang the basic le structure 284
Creang 2D arrays 285
Time for acon – creang 2D arrays 286
Storing informaon… the data storage 286
Time for acon – creang the data structure 287
First changes to the OnCreate event 289
Time for acon – rst changes to the OnCreate method 290
About the OnRender event 290
Seng up the game objects 290

Klick, bang, swoosh… the sound eects! 290
Time for acon – loading the game sound eects 291
Lay your head on me…. the game layers 291
Time for acon – creang layers for the game 291
Our beloved play eld—the background screen 292
Time for acon – composing the background screen 292
Give it a name… the tle screen 293
Time for acon – creang the tle screen 293
Game over… creang the "game over" screen 294
Time for acon – creang the "game over" screen 294
The menu please… creang the menu screen 295
Buons … I need more text buons! 295
Time for acon – creang text buons 295
The menu screen 296
Time for acon – creang the menu screen 296
What is the score?… creang the high-score screen 297
Time for acon – creang the score screen 297
Layer acvaon 298
Time for acon – creang the acvate layer method 298
Finalizing the OnCreate event 300
Time for acon – nalizing the OnCreate method 300
Dealing with the high-score list 301
Loading and saving the list 301
Time for acon – loading and saving the high-score list 301
Showing the high-score screen 302
Table of Contents
[ xiv ]
Time for acon – showing the high-score list 302
Managing the le map 303
Geng le map slot IDs 303

Time for acon – geng le slot IDs 303
Seng le map slot IDs 304
Time for acon – seng a le slot ID 304
Check/mark the neighboring les 304
Time for acon – checking neighboring horizontal les 305
Time for acon – check neighboring vercal les 307
Clearing les 308
Time for acon – clearing the le map 308
Counng matching les 309
Time for acon – counng matching les 309
The precious one… creang a gem 310
Time for acon – creang a gem 310
Relling the le map 311
Time for acon – relling the le map 311
Methods for the update process 313
Starng a new game 314
Time for acon – creang a StartNewGame method 314
Give me some informaon… displaying info 316
Time for acon – updang the text info 316
Showing the "game over" screen 317
Time for acon – showing the 'game over' screen 317
Showing the menu screen 318
Time for acon – showing the menu 318
Bring me up-to-date—detailing the OnUpdate event 318
Time for acon – detailing the OnUpdate method 318
Vroom… vroom—the engine class 320
Eye candy—parcle eects 321
Time for acon – spawning an explosion 321
Tick tock… acng on object mer events 322
Time for acon – acng on object mer events 322

Touch me—acng on Touch checks 323
Time for acon – enhancing the OnObjectTouch method 323
We've reached our parking posion… a transion is done 326
Time for acon – detailing the OnObjectTransion method 326
What's the situaon?… layer update events 327
Time for acon – acng on layer update events 327
Summary 328
Table of Contents
[ xv ]
Chapter 10: Make Some Money for Bananas 329
Which markets exist for your game? 330
iOS 330
OSX 330
Android 330
XNA 330
HTML5/FLASH 330
Exisng methods of making money 330
Selling your game at a xed price 331
Subscripons 331
Adversement 331
In-App purchases 331
Implemenng adversing in your app 332
Which ad providers exist? 332
Implemenng AdMob 332
iOS 333
Android 333
Implemenng MobFox in iOS 333
Signing up at MobFox 333
Creang the ID for an iOS app in MobFox 333
Time for acon – creang a new MobFox app ID 334

Implemenng MobFox into your XCODE project 336
Time for acon – adding the MobFox framework to the XCODE project 336
Displaying MobFox ads in the app 338
Time for acon – modifying the code to display ads 338
Acvang real ads 342
Implemenng MobFox in Android 343
Creang the ID for an Android app in MobFox 343
Time for acon – creang a new MobFox app ID 343
Implement MobFox into your Android project 345
Time for acon – modifying the project to display ads in Android 345
Adding a backll through InMobi 348
Signing up at InMobi 348
Create an Android app in InMobi 349
Time for acon – creang an app ID in InMobi 349
Seng the backll opon in MobFox 350
Time for acon – add a backll in MobFox 351
Publishing in the Android market 352
Create app icons 352
Change the app label and the package name 352
Seng the version code and name 352
Rename the app package 353
Table of Contents
[ xvi ]
Remove the debug key from the package 353
Create a private key to sign the app with 353
Sign the package with your new private key 353
Zipalign your app package 354
Publishing in Apple's App Store 354
Add the app icons 354
Time for acon – adding an icon to the Xcode project 355

Time for acon – seng the product name in the target sengs 356
Set the distribuon code signing prole 357
Time for acon – seng the distribuon code signing prole 357
Create a package to submit 358
Time for acon – creang the app package 358
Summary 359
Index 361

×