Monkey Game Development
Beginner's Guide
Create monezed 2D games deployable to almost
any plaorm
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 transmied in any form or by any means, without the prior wrien permission of the
publisher, except in the case of brief quotaons embedded in crical arcles or reviews.
Every eort has been made in the preparaon of this book to ensure the accuracy of the
informaon presented. However, the informaon 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 informaon about all of the
companies and products menoned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this informaon.
First published: April 2012
Producon 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
Acquision Editor
Karkey 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
Producon Coordinator
Melwyn D'Sa
Cover Work
Melwyn D'Sa
About the Author
Michael Hartlef has been into game development for a long long me, starng in 1984,
at the early age of 18, with this great hobby called developing computer games, on the
Commodore C64. Aer 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 specic 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 ulity 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
Jusn for having so much paence with me during the me of wring 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 acve as a Level Designer, World Builder, and Interacve Storyteller
for a long me, in capacies ranging from community Mod projects, to student work, to
indie producon. During this me, he has gathered a lot of experience in dierent editors
and producon sengs, 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 creaon of interesng 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 oer challenges for groups of players out for an adventure.
This included seng up encounters with enemies, seng up the ambient eects, creang
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 pracce 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 producon 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, dramac 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 Instute of Vancouver to learn more on the topic and worked with big student groups to
make games. From high-level scripng to low-level programming, she worked hard to learn
the art of the trade.
Aer 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 oers 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 entled 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 collecon of free technical arcles, sign up for
a range of free newsleers and receive exclusive discounts and oers on Packt books and
eBooks.
Do you need instant soluons to your IT quesons? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's enre 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 enrely free books. Simply use your login credenals for
immediate access.
Table of Contents
Preface 1
Chapter 1: Monkey—Huh? 7
Game development for the rest of us 8
Cross-plaorm development 8
Compiler or translator? 8
The Monkey toolbox 9
Time for acon – installing Monkey 10
Please welcome… Monk 10
MSERVER—Monkey's own web server 11
Let's have a lile playme 12
Time for acon – playing Pirate TriPeaks 12
Time for acon – playing Surviball 14
Playing to have fun, playing to study 15
So let's go for something big? No! 15
The alternave 15
Time for acon – read the manual 16
The Trans tool and the supported target plaorms 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
Nave source code 23
Third-party modules 24
Your own targets 24
Your game is easily portable 24
Summary 25
Chapter 2: Geng 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
Starng up Monk 28
Monk's user interface 29
The toolbar 29
The code editor area 29
The info box 29
Time for acon – opening a sample script 30
Where is my navi? 31
Time for acon – navigang to the Main() funcon 32
Save save save! 32
Time for acon – saving a script 32
Projects—bringing in some organizaon 33
Time for acon – creang a project 33
The Monkey programming language 34
Time for acon – Monkey's Hello World 34
Running your rst script in a browser 35
Our rst lile game PONGO 36
Time for acon – the basic structure of your game 36
Pongo's data structure 38
Time for acon – adding some data elds 38
Time for acon – rendering the game eld 39
Time for acon – drawing the ball and the paddles 40
Time for acon – player paddle movement 41
Time for acon – moving the enemy paddles 42
Time for acon – moving the ball 43
Time for acon – controlling the ball with the player's paddle 45
Time for acon – leng the enemy paddles ght back 46
Time for acon – acng on the dierent game modes 48
Table of Contents
[ iii ]
Exporng 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 acon – building the basic le structure of the game 55
Hold that data—RocketCommander's data structure 58
Time for acon – creang the general data structure of the game 58
Detailing the Update process 59
Time for acon – detailing the Update process 59
Detailing the Render process 60
Time for acon – detailing the Render event 60
Enhancing the OnCreate event 62
Time for acon – detailing the OnCreate process 62
Let's build some cies 63
Time for acon – building some cies 63
Implemenng the city class into the game 66
Time for acon – changing the gameClasses le 66
Modifying the RocketCommander class 66
Time for acon – spawning some cies in the game 67
Rendering the ground and the cies 67
Time for acon – rendering the cies 67
Get the launchers ready! 68
Time for acon – implemenng the rocket launchers 68
Implemenng the launcher class into the game 72
Time for acon – changing the gameClasses le again 73
Modifying the RocketCommander class 73
Time for acon – creang some launchers in the game 73
Updang the rocket launchers 74
Time for acon – updang the launchers 74
Enhancing the UpdateMenu method 74
Time for acon – modifying the menu update process 74
Rendering our precious rocket launchers 75
Time for acon – rendering the launchers 75
Fire! Blast them to pieces! 76
Time for acon – implemenng some rockets 76
Implemenng the rocket class into the game 80
Time for acon – modifying the gameClasses le 80
Modifying the launcher class 80
Table of Contents
[ iv ]
Time for acon – modifying the launcher class 81
Updang the rockets 81
Time for acon – updang the rockets 81
Rendering our furious rockets 81
Time for acon – rendering the rockets 82
And it goes BOOM! Explosions 82
Time for acon – implemenng explosions 82
Implemenng the explosion class into the game 84
Time for acon – modifying the gameClasses le 84
Modifying the rocket class 85
Time for acon – modifying the rocket class 85
Updang the explosions 85
Time for acon – updang the explosions 85
Rendering beauful explosions 86
Time for acon – rendering the explosions 86
Don't fear the enemy—bombs 86
Time for acon – creang the bomb class 86
Implemenng the bomb class into the game 91
Time for acon – modifying the gameClasses le 91
Updang bombs 91
Time for acon – updang the bombs 92
Rendering beauful bombs 92
Time for acon – rendering the bombs 92
Creang new bombs and checking for GameOver condions, or new level
condions 93
Time for acon – modifying the UpdateGame method 93
Displaying the game score 94
Time for acon – 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
Parcles 104
Game info text 104
The basic le structure 104
Time for acon – create the main source le and its folders 104
Open the storage please—the data structure of CometCrusher 107
Time for acon – creang the data structure 107
First changes to the OnCreate method 109
Time for acon – modifying the OnCreate method 109
Detailing the Render process 110
Time for acon – detailing the OnRender method 110
This is a setup—creang the game objects 110
Group yourself—layers 110
Time for acon – creang some layers 111
Let them shine—the background stars 111
Time for acon – implemenng some stars 111
The Hero—creang the player ship 112
Time for acon – seng up the player ship 112
Did you hear that—loading sounds 114
Time for acon – creang a method to load sounds 114
Did you see that score—the game UI 115
Time for acon – creang some game info text objects 115
Headlines—adding a tle screen 116
Time for acon – adding a tle screen 116
How good are you—the high score list 117
Time for acon – seng up the high score list 117
Rocks rocks rocks—ll the space with some comets 118
Time for acon – create a comet 118
Time for acon – creang some comets 119
Mission complete nalizing the OnCreate process 120
Time for acon – 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 acon – loading a high score list 122
Time for acon – showing the high score list 122
Acvang the shield of the player ship 123
Time for acon – the AcvateShield method 123
Delta me related movement 124
Time for acon – determine the me delta 124
Updang the game stasc info text objects 124
Table of Contents
[ vi ]
Time for acon – updang the info text 125
Starng a new game 125
Time for acon – creang a StartNewGame method 125
Let the engine glow 126
Time for acon – spawning some engine parcle FX 126
And it goes boom—creang an explosion 127
Time for acon – creang some explosions 127
Give me that gun—spawning a shot 128
Time for acon – spawning some shots 128
Save some high scores, will ya! 129
Time for acon – saving the high score list 129
Finalizing the OnUpdate method 130
Time for acon – nalizing the OnUpdate method 130
Bring in the acon—shaping the engine class 132
Crack these objects—object collision handling 132
Time for acon – detailing the collision detecon 132
It's about me—acng on mer events 134
Time for acon – detailing the OnObjectTimer method 134
Everything is under control—object update events 135
Time for acon – detailing the OnObjectUpdate method 135
Did I win—checking the losing condions with OnLayerUpdate 136
Time for acon – detailing the OnLayerUpdate method 136
One last thing—creang a FLASH game 138
Summary 139
Chapter 5: Game #4, Chain Reacon 141
Modifying the HTML5 canvas size 142
Time for acon – 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
Animaon 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 acon – creang the main source le and its folders 147
The data storage 150
Time for acon – creang the data structure 150
First changes to the OnCreate event 152
Time for acon – rst changes to the OnCreate method 152
Detailing the OnRender event 153
Time for acon – detailing the OnRender method 153
Seng up the game objects 154
Sound eects 154
Time for acon – loading the game sound eects 154
Game layers 154
Time for acon – creang layers for the game 154
Game screen 155
Click here – Adding buons 155
Time for acon – creang buons 155
The info text objects 156
Time for acon – creang info text objects 156
The actual game screen 157
Time for acon – composing the game screen 157
Title screen 158
Time for acon – creang the tle screen 158
Finalizing the OnCreate event 159
Time for acon – nalizing the OnCreate method 159
Helper funcons for the update process 159
Creang the atom elements 159
Collision circle objects 160
Time for acon – creang collision circles 160
Atom elements 160
Time for acon – creang the atom elements 161
Starng a new game 163
Time for acon – creang a StartNewGame method 163
Time-related movement 164
Time for acon – implemenng the GetDeltaTime method 164
Updang the info text objects 165
Time for acon – creang a method to update the text informaon 165
Detailing the OnUpdate event 165
Time for acon – nalizing the OnUpdate method 166
Introducing the OnSuspend event 167
Time for acon – modifying the OnSuspend event 167
Table of Contents
[ viii ]
Introducing the OnResume event 168
Time for acon – updang the OnResume method 168
The heart of the game - the engine class 169
What are transions? 169
Touch me – acng on touch hits 169
Time for acon – enhancing the OnObjectTouch method 169
The eagle has landed—a transion is nished 171
Time for acon – detailing the OnObjectTransion method 171
It's about me—mer events 171
Time for acon – acng on mer events 172
Captain! Collision ahead!—doing collision checks 172
Time for acon – detailing the collision detecon 173
Creang an Android app 174
Changing icons 174
Do a name change 175
Signing an applicaon 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 acon – creang the basic le structure 180
Modifying the HTML5 canvas size for tesng 181
Time for acon – modifying the HTML5 output 181
The data storage 182
Time for acon – creang the data structure 182
First changes to the OnCreate event 184
Time for acon – rst changes to the OnCreate method 184
Detailing the OnRender event 185
Time for acon – detailing the OnRender method 185
Seng up the game objects 185
Make some noise—sound eects 186
Time for acon – loading the game sound eects 186
Table of Contents
[ ix ]
Lay your head on me—the game layers 186
Time for acon – creang layers for the game 186
Our beloved play eld—the background screen 187
Buons—I need more text buons! 187
Time for acon – creang text buons 187
The background screen as usual 188
Time for acon – composing the game screen 188
Give it a name—the tle screen 189
Time for acon – creang the tle screen 189
Finalizing the OnCreate event 190
Time for acon – nalizing the OnCreate method 190
Helper methods for the update process 191
Creang the les 191
Time for acon – creang the les 191
The main actor—creang the ball 193
Time for acon – creang the ball 193
The bad guys—our beloved enemies 194
Time for acon – creang the enemy class 194
More helper funcons 197
Spawning an enemy 197
Time for acon – spawning an enemy 197
Starng a new game 197
Time for acon – creang a StartNewGame method 198
Bring me up-to-date—detailing the OnUpdate event 199
Time for acon – detailing the OnUpdate method 199
Eye candy—parcle eects 200
The parcle emier class 201
Time for acon – creang the parcle emier class 201
The last helper method 203
Time for acon – spawning a parcle emier 203
The heart of the game—the engine class 204
Touch me—acng on touch hits 204
Time for acon – enhancing the OnObjectTouch method 204
Controlling the ball—acng on object update events 205
Time for acon – acng on object update events 205
What's the situaon? Layer update events 207
Time for acon – acng on layer update events 207
We reached our parking posion—a transion is done 209
Time for acon – detailing the OnObjectTransion method 209
Bump bump—checking for collisions 210
Time for acon – detailing the collision detecon 210
Table of Contents
[ x ]
Creang 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 acon – creang the basic le structure 218
Modifying the HTML5 canvas size for tesng 219
Time for acon – modifying the HTML5 output 219
The storage for our data 219
Time for acon – creang the data structure 220
Seng up the game objects 222
Slice over slice—game layers 222
Time for acon – creang layers for the game 222
The second-most important part—a tle screen 222
Time for acon – creang the tle screen 223
Detailing the OnCreate event 224
Time for acon – nalizing the OnCreate method 224
Some exible methods for the update process 225
Lads and gents… the main actor 226
Time for acon – creang the player 226
The level maps—loading the les 227
Time for acon – loading the level les 228
On your marks—starng a new game 233
Time for acon – creang a StartNewGame method 233
Bring me up-to-date—detailing the OnUpdate event 233
Time for acon – detailing the OnUpdate method 234
And acon!—the engine class 236
Move it… object updates 236
Time for acon – updang each object 236
Table of Contents
[ xi ]
Push push—checking for collisions 238
Time for acon – detailing collision detecon 238
I can't see it anymore—the transion is nished! 239
Time for acon – detailing the OnLayerTransion method 240
Creang 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 parcles 247
Explosions 247
The basic app structure 247
Time for acon – seng up the basic le structure 248
Storing data 248
Time for acon – creang the data structure 248
First changes to the OnCreate event 250
Time for acon – rst changes to the OnCreate method 251
Seng up the game objects 251
Making some noise… sound eects! 251
Time for acon – loading the game sound eects 252
Lay your head on me… the game layers 252
Time for acon – creang layers for the game 252
Over high ground—the background screen 253
Time for acon – composing the background screen 253
Hope it won't rain—creang the clouds 254
Time for acon – creang the clouds 254
What is going on?—creang info text objects 255
Time for acon – creang info text objects 256
What are we playing here?—The tle/menu screen 256
Time for acon – creang the tle screen 257
Finalizing the OnCreate event 258
Table of Contents
[ xii ]
Time for acon – nalizing the OnCreate method 258
Methods for the update process 259
The hero—spawning the player plane 259
Time for acon – spawning the player plane 259
Spawning an enemy 260
Time for acon – spawning an enemy plane 260
Starng a new game 261
Time for acon – creang a StartNewGame method 261
Detailing the OnUpdate event 262
Time for acon – detailing the OnUpdate method 263
Making it look nicer—some parcle eects 265
Eming smoke 265
Time for acon – eming the smoke 265
Boom!—Eming explosions 266
Time for acon – creang the explosion 267
Pow!—spawning a shot 268
Time for acon – spawning a shot 268
The brain—Computer AI (Arcial Intelligence) 270
Follow him!—creang a brain for the enemy pilot 270
Time for acon – following the player 270
The heart of the game—the engine class 271
Time management—acng on object mer events 271
Time for acon – enhancing the OnObjectTimer method 271
It is gone!—a transion is done 272
Time for acon – detailing the OnObjectTransion method 272
Controlling the player plane—acng on object update events 272
Time for acon – acng on object update events 272
Hit it!—handling collision response 274
Time for acon – detailing the collision response 274
Did I win?—layer update events 276
Time for acon – acng of layer update events 276
Creang 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
Parcle eects 284
Preparaon… the basic app and project structure 284
Time for acon – creang the basic le structure 284
Creang 2D arrays 285
Time for acon – creang 2D arrays 286
Storing informaon… the data storage 286
Time for acon – creang the data structure 287
First changes to the OnCreate event 289
Time for acon – rst changes to the OnCreate method 290
About the OnRender event 290
Seng up the game objects 290
Klick, bang, swoosh… the sound eects! 290
Time for acon – loading the game sound eects 291
Lay your head on me…. the game layers 291
Time for acon – creang layers for the game 291
Our beloved play eld—the background screen 292
Time for acon – composing the background screen 292
Give it a name… the tle screen 293
Time for acon – creang the tle screen 293
Game over… creang the "game over" screen 294
Time for acon – creang the "game over" screen 294
The menu please… creang the menu screen 295
Buons … I need more text buons! 295
Time for acon – creang text buons 295
The menu screen 296
Time for acon – creang the menu screen 296
What is the score?… creang the high-score screen 297
Time for acon – creang the score screen 297
Layer acvaon 298
Time for acon – creang the acvate layer method 298
Finalizing the OnCreate event 300
Time for acon – nalizing the OnCreate method 300
Dealing with the high-score list 301
Loading and saving the list 301
Time for acon – loading and saving the high-score list 301
Showing the high-score screen 302
Table of Contents
[ xiv ]
Time for acon – showing the high-score list 302
Managing the le map 303
Geng le map slot IDs 303
Time for acon – geng le slot IDs 303
Seng le map slot IDs 304
Time for acon – seng a le slot ID 304
Check/mark the neighboring les 304
Time for acon – checking neighboring horizontal les 305
Time for acon – check neighboring vercal les 307
Clearing les 308
Time for acon – clearing the le map 308
Counng matching les 309
Time for acon – counng matching les 309
The precious one… creang a gem 310
Time for acon – creang a gem 310
Relling the le map 311
Time for acon – relling the le map 311
Methods for the update process 313
Starng a new game 314
Time for acon – creang a StartNewGame method 314
Give me some informaon… displaying info 316
Time for acon – updang the text info 316
Showing the "game over" screen 317
Time for acon – showing the 'game over' screen 317
Showing the menu screen 318
Time for acon – showing the menu 318
Bring me up-to-date—detailing the OnUpdate event 318
Time for acon – detailing the OnUpdate method 318
Vroom… vroom—the engine class 320
Eye candy—parcle eects 321
Time for acon – spawning an explosion 321
Tick tock… acng on object mer events 322
Time for acon – acng on object mer events 322
Touch me—acng on Touch checks 323
Time for acon – enhancing the OnObjectTouch method 323
We've reached our parking posion… a transion is done 326
Time for acon – detailing the OnObjectTransion method 326
What's the situaon?… layer update events 327
Time for acon – acng 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
Exisng methods of making money 330
Selling your game at a xed price 331
Subscripons 331
Adversement 331
In-App purchases 331
Implemenng adversing in your app 332
Which ad providers exist? 332
Implemenng AdMob 332
iOS 333
Android 333
Implemenng MobFox in iOS 333
Signing up at MobFox 333
Creang the ID for an iOS app in MobFox 333
Time for acon – creang a new MobFox app ID 334
Implemenng MobFox into your XCODE project 336
Time for acon – adding the MobFox framework to the XCODE project 336
Displaying MobFox ads in the app 338
Time for acon – modifying the code to display ads 338
Acvang real ads 342
Implemenng MobFox in Android 343
Creang the ID for an Android app in MobFox 343
Time for acon – creang a new MobFox app ID 343
Implement MobFox into your Android project 345
Time for acon – modifying the project to display ads in Android 345
Adding a backll through InMobi 348
Signing up at InMobi 348
Create an Android app in InMobi 349
Time for acon – creang an app ID in InMobi 349
Seng the backll opon in MobFox 350
Time for acon – add a backll in MobFox 351
Publishing in the Android market 352
Create app icons 352
Change the app label and the package name 352
Seng 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 acon – adding an icon to the Xcode project 355
Time for acon – seng the product name in the target sengs 356
Set the distribuon code signing prole 357
Time for acon – seng the distribuon code signing prole 357
Create a package to submit 358
Time for acon – creang the app package 358
Summary 359
Index 361