Foundation Game Design With Actionscript 3.0 2nd Edition

cabbagetreatmentSoftware and s/w Development

Jul 4, 2012 (5 years and 3 months ago)

469 views

Foundation Game Design With Actionscript 3.0 2nd
Edition
Details:
678 pages
This book takes the approach of letting you create graphics with any software, and then using Flash Builder or Flash Develop to develop
the ActionScript code
Foundation Game Design With Actionscript 3.0 2nd Edition - Table of Contents
Notes
Chapter 1
2nd Edition designed not depend on Flash Professional.
Free or low cost software
Graphics
Suggests use of
with
(makes Gimp look like photoshop to make tutorials
http://www.gimp.com
http://www.gimpshop.com
easier to follow)
Finding tutorials: photoshop tutorials for beginners
http://www.aviary.com
http://www.adobe.com/products/photoshopel/
- Photoshop Elements excellent low cost version of Photoshop
IDE
Flash Develop
http://www.flashdevelop.org
Info about installing debug version of Flash Player
Programming? But I’m terrible at math!
Recommends the book
for more on math
Foundation ActionScript 3.0 Animation Making Things Move
I already know how to program! - Jump to chapter 4.
What kind of games can I make? - 2D action, adventure and arcade games, and a little on puzzle and logic games.
No 3D games.
Doesn't deal with multi-player games
Basic introduction Flash Builder - Writing Hello World - explains packages, classes, etc.
Calls things like trace, or import statement, a "directive" - instead of statement
Advice on dealing with compilation errors
Editing window quirks and features
Collapsing code, breakpoints
Chapter 2: Making Game Graphics
Create a game world background
Draw the sky, hills, pen tool
Use PNG format because it preserves transparency, but it wont make it easy to do additional editing. so save the PSD files too.
Making characters, buttons,
Chapter 3: Programming Objects
But I’m a bit scared of programming! - Programming is a creative tool.
Loading and displaying images
Basic process:
Load the image with a loader, put the image in a sprite (or a MovieClip, or a Bitmap), and add the sprite to the stage.
Set up the Flash Player with a metadata tag
[SWF(width="550", height="400", backgroundColor="#FFFFFF, frameRate="60")]
This must be after the imports, and before the class definition.
Loading and displaying the background.png image - book page 130
public var backgroundURL:URLRequest;
public var backgroundLoader:Loader;
public var background:Sprite;
public function GameWorld()
{
//Add the background to the stage
backgroundURL = new URLRequest();
backgroundLoader = new Loader();
background = new Sprite();
backgroundURL.url = "../images/background.png";
backgroundLoader.load(backgroundURL);
background.addChild(backgroundLoader);
stage.addChild(background);
}
Several pages of description of this: declarations (variables as empty boxes), creating objects, assignment operator,
Error of not finding an image because the file or directory is not in the specified place: "No active Security context"
What if you want to use the graphic in an MXML Flex application such as an AIR application?
Here is a program that works similar to the above:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
frameRate="60"
width="550"
height="400"
backgroundColor="#ffffff"
applicationComplete="win_applicationCompleteHandler(event)"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<fx:Script>
<![CDATA[
import mx.events.FlexEvent;

[Bindable]
[Embed(source='images/background.png')]
private var backgroundGraphic:Class;
private var backgroundBitmap:Bitmap;

protected function win_applicationCompleteHandler(
event:FlexEvent):void
{
var O:Object = new backgroundGraphic();
backgroundBitmap = Bitmap(O);
stage.addChild(backgroundBitmap);
}


]]>
</fx:Script>
</s:WindowedApplication>
There are some differences:
Instead of a Sprite, we use the Bitmap object
We use embed metatag to embed the bitmap image into the AIR application
When loading a bitmap image, creating a new object creates an object of the Bitmap type.
Stage is not available in the initialize event, it is null. So this must be done int he applicationComplete event handler.
Read to PDF Page 155
Displaying the image on the stage
Understanding the code structure
Positioning Sprites on the stage
Programming buttons
Understanding dot notation ....... 159
Methods ........ 159
Using method calls ....... 160
Using function definitions ...... 161
Using a basic method ....... 163
Understanding events and event listeners ... 168
Making your buttons work ..... 177
Controlling Sprite objects with properties..... 178
Going up and down ....... 180
Moving incrementally ....... 182
Tracing the output ..... 183
Using increment and decrement operators ...... 184
Limiting movement ........ 185
Making it bigger and smaller ..... 189
Vanishing! ..... 192
Spinning around ........ 195
More properties? ....... 198
Centering Sprites ..... 198
Code summary ..... 202
*Summary ....... 206
Chapter 4: Decision Making ....... 209
Using text ..... 210
Setting up the project .... 210
The classes you have to import .... 212
Creating TextFormat and TextField objects ..... 213
Setting the format of text ....... 214
Configuring and displaying the output text ... 216
Configuring and displaying the input field ..... 218
Building a simple guessing game .... 222*
Understanding the program structure ... 222*
Learning more about variables .... 224
Listening for key presses ...... 227
Making decisions ...... 231
Displaying the game status ....... 238
Using postfix operators to change variable values by one .. 240
Tying up strings..... 241
Hey, why use the gameStatus variable, anyway? .... 245
Using uint vs. int variables .... 245
Winning and losing ....... 246
Modular programming with methods .... 252
Polishing up ...... 253
Tackling random numbers .... 254
Disabling the Enter key ..... 258
Making really nice buttons ....... 260
Understanding the concepts ..... 262
Loading the images and displaying the button ..... 263
Understanding the mouse events ..... 265
Adding the button to the number guessing game .... 271
Disabling the button at the end of the game ..... 272
Managing complex code ....... 278
Project extensions ........ 279
Make a Play again button ..... 279
Tracking guesses ...... 280
Adding a visual display ..... 281
Turning the tables ..... 281
A quick guide to embedding fonts .... 281
Summary ...... 284
Chapter 5: Controlling A Player Character ... 285
Controlling a player character with the keyboard..... 285
Controlling with the keyboard---the wrong way! ... 286
Controlling the keyboard---the right way! ...... 290
Moving with velocity ...... 292
Using the new keyDownHandler ....... 294
Using the keyUpHandler ....... 294
Using the enterFrameHandler ...... 296
Setting stage boundaries ...... 298
Blocking movement at the stage edges.... 298
Screen wrapping ....... 303
Embedding images ...... 304
Scrolling ....... 307
Looking at the code ...... 310
Better scrolling ...... 313
Even better scrolling ..... 320
Taking it further ........ 323
Parallax scrolling ....... 324
Summary
Chapter 6: Bumping Into Things ... 331
Basic collision detection with hitTestObject ...... 331
Using hitTestObject ...... 335
Triggering a change of state .... 337
Reducing a health meter ....... 341
Using scaleX to scale the meter based on a percentage ..... 343
Updating a score ....... 344
Picking up and dropping objects ....... 351
The bad news about hitTestObject ...... 357
Detecting collisions with the bounding box ... 358
Learning to live with it ....... 359
Creating subobjects ...... 360
Advanced collision detection strategies .... 364
Working with vector based collision detection ..... 365
Preventing objects from overlapping .... 365*
Programming with the Collision class ... 373*
Another look at methods, arguments, and parameters ..... 378
Taking a look at the Collision.block method ..... 381
Summary ...... 387
Chapter 7: Making Games ...... 389
Making the game graphics ....... 390
Making the textured box ....... 391
Making the bomb ...... 407
Making a game character ..... 416
Designing the playing field .... 429
Making the Game Over graphic .... 430
Programming the game ....... 432
Dealing with many objects .... 432
What is a class, really? ..... 434
Looking at the TimeBombPanic application class .... 439
Adding objects to the game ...... 444
Stage boundaries ...... 446
Collisions between the character and the boxes ...... 447
Defusing the bombs ...... 447
Using a timer ..... 448
Ending the game ....... 453
Creating a scrolling game environment ... 456
Preparing your artwork for scrolling ...... 457
Adding objects to the game ...... 458
Scrolling and stage boundaries .... 460
*Summary ...... 463
Chapter 8: Making Bigger Games ..... 465
Understanding the game structure ....... 466
Using private variables and methods ... 469
Programming the game ....... 471
Giving LevelOne access to the stage ... 471
Making sure that LevelOne is actually on the stage ..... 472
The LevelOne class ...... 475
Programming the game character .... 482
Programming the monsters ...... 489
Programming the star weapon ...... 495
Checking for the end of the level ...... 503
Ending the level ........ 505
Using removeChild to completely get rid of objects ...... 513
Communicating between classes by dispatching events ..... 514
Event bubbling ...... 516
Finishing off level one ....... 518
Firing stars in four directions in level two ..... 519
More Monster Mayhem! ....... 522
Moving objects in a scrolling game world ..... 522
Intelligent monsters ....... 537
Obstacles and pathfinding .... 540
A little more about game structure ....... 541
Summary ...... 543
Chapter 9: Physics, Loops, Arrays, and Sounds ..... 545
Natural motion using physics ....... 545
A game object class for playing with physics ... 546
Acceleration ...... 548
Friction ...... 555
Bouncing ....... 557
Gravity ....... 559
Jumping ........ 561
Adding sounds to games ..... 567
Integrating sound effects in a game ..... 569
Looping music and setting volume and pan levels ... 570
Working with many objects ...... 575
Using arrays ...... 580
Making many boxes ...... 589
Collisions with many objects ..... 596
Case studies ..... 603
Summary ...... 604
Chapter 10: Advanced Object And Character Control .... 605
Moving objects with the mouse .... 606
Fixing an object to the mouse’s position ... 606
Moving an object with easing .... 607
Case study: Firing projectiles in all directions ...... 613
Making the game objects ...... 617
Rotating the wand around the fairy ....... 618
Firing stars in 360 degrees ....... 620
Advanced player control systems .... 623
Enemy AI systems ....... 624
Running away from the player ...... 627
Rotating and shooting toward the mouse ..... 628
Using a timer to fire bullets ....... 631
Case study: Killer Bee Pandemonium! .... 632
Flash animation and publishing your game ...... 640
Index ... 643