ActionScript 3.0 Game Programming University, 2nd Edition

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learn ActionScript 3.0 the fun way, by creating 16 great games: real, robust games – not just “web toys”!Highly-rated ActionScript tutorial, now with seven new 3D and card games! Code and techniques easily adaptable to training, advertising, and more For Flash artists learning ActionScript, Flash programmers seeking to create games, and upgraders from ActionScript 1.0/2.0. Includes a chapter on developing games in Flash for the iPhone!

Author(s): Gary Rosenzweig
Publisher: Que
Year: 2011

Language: English
Commentary: 1181369448
Pages: 592
Tags: Библиотека;Компьютерная литература;Flash / Action Script;

Contents......Page 5
Introduction......Page 20
Flash and Game Development......Page 21
Prerequisite Knowledge......Page 22
Using the Example Games in Your Projects......Page 23
The FlashGameU.com Website......Page 24
1. Using Flash and ActionScript 3.0......Page 26
What Is ActionScript 3.0?......Page 27
A Simple Use of trace......Page 28
Creating Screen Output......Page 31
Our First ActionScript 3.0 Class......Page 33
Display Objects and Display Lists......Page 35
The Library......Page 36
The Timeline......Page 37
Writing and Editing ActionScript......Page 38
Smallest-Step Approach......Page 41
Good Programming Practices......Page 42
Creating and Using Variables......Page 45
Condition Statements......Page 46
Loops......Page 47
Types of Bugs......Page 48
Using the Debugger......Page 49
Formats......Page 52
Flash......Page 53
HTML......Page 54
Publishing and Document Settings......Page 55
Class, Function, and Variable Names......Page 56
Runtime Issues......Page 57
Testing Issues......Page 58
2. ActionScript Game Elements......Page 60
Using Movie Clips......Page 61
Making Buttons......Page 63
Drawing Shapes......Page 66
Drawing Text......Page 68
Creating Linked Text......Page 70
Creating Sprite Groups......Page 72
Setting Sprite Depth......Page 74
Mouse Input......Page 75
Keyboard Input......Page 76
Text Input......Page 77
Creating Animation......Page 79
Using Timers......Page 81
Time-Based Animation......Page 82
Physics-Based Animation......Page 83
Moving Sprites......Page 84
Dragging Sprites......Page 87
Collision Detection......Page 88
External Variables......Page 89
Loading Data......Page 91
Saving Local Data......Page 92
Custom Cursors......Page 93
Playing Sounds......Page 94
Loading Screen......Page 96
Random Numbers......Page 97
Shuffling an Array......Page 98
Displaying a Clock......Page 99
System Data......Page 100
Game Theft and Security......Page 101
3. Basic Game Framework: A Matching Game......Page 104
Methods for Creating Game Pieces......Page 105
Setting Up the Flash Movie......Page 107
Creating the Basic ActionScript Class......Page 108
Using Constants for Better Coding......Page 111
Shuffling and Assigning Cards......Page 113
Adding Mouse Listeners......Page 115
Setting Up Game Logic......Page 117
Checking for Game Over......Page 120
Encapsulating the Game......Page 122
Creating the Game Movie Clip......Page 123
Adding an Introduction Screen......Page 124
Adding a Play Again Button......Page 125
Adding Scoring......Page 126
Adding a Clock......Page 129
Displaying Time......Page 131
Displaying Score and Time After the Game Is Over......Page 132
Animated Card Flips......Page 134
Limited Card-Viewing Time......Page 136
Sound Effects......Page 138
Modifying the Game......Page 139
4. Brain Games: Memory and Deduction......Page 142
Arrays......Page 143
Data Objects......Page 145
Memory Game......Page 146
Preparing the Movie......Page 147
Programming Strategy......Page 148
Class Definition......Page 149
Setting the Text, Lights, and Sounds......Page 151
Playing the Sequence......Page 154
Switching Lights On and Off......Page 155
Accepting and Checking Player Input......Page 156
Modifying the Game......Page 158
Deduction Game......Page 159
Setting Up the Movie......Page 160
Defining the Class......Page 162
Starting a New Game......Page 164
Checking Player Guesses......Page 166
Evaluating Player Moves......Page 167
Ending the Game......Page 170
Clearing Game Elements......Page 172
Modifying the Game......Page 173
5. Game Animation: Shooting and Bouncing Games......Page 176
Time-Based Animation......Page 177
Coding Time-Based Animation......Page 179
Air Raid......Page 182
Movie Setup and Approach......Page 183
Flying Airplanes......Page 184
Moving Gun......Page 187
Skyward Bullets......Page 191
The Game Class......Page 193
Modifying the Game......Page 200
Setting Up the Movie......Page 201
Class Definition......Page 204
Starting the Game......Page 205
Starting a New Ball......Page 207
Game Animation and Collision Detection......Page 208
Game Over......Page 214
Modifying the Game......Page 215
6. Picture Puzzles: Sliding and Jigsaw......Page 216
Loading a Bitmap......Page 217
Breaking a Bitmap into Pieces......Page 219
Sliding Puzzle Game......Page 221
Setting Up the Class......Page 222
Cutting the Bitmap into Pieces......Page 225
Shuffling the Pieces......Page 227
Reacting to Player Clicks......Page 230
Animating the Slide......Page 232
Game Over and Cleanup......Page 233
Jigsaw Puzzle Game......Page 234
Setting Up the Class......Page 235
Loading and Cutting the Image......Page 236
Dragging Puzzle Pieces......Page 240
Game Over......Page 245
Modifying the Game......Page 246
7. Direction and Movement: Air Raid II, Space Rocks, and Balloon Pop......Page 248
The Sin and Cos Functions......Page 249
Using Cos and Sin to Drive a Car......Page 251
Calculating an Angle from a Location......Page 254
Altering the Gun......Page 258
Changing the Bullets......Page 260
Changes to AirRaid2.as......Page 262
Game Elements and Design......Page 264
Setting Up the Graphics......Page 266
Setting Up the Class......Page 267
Starting the Game......Page 269
Score and Status Display Objects......Page 270
Ship Movement and Player Input......Page 273
Shields Up!......Page 278
Rocks......Page 279
Missiles......Page 282
Game Control......Page 284
Modifying the Game......Page 286
Game Elements and Design......Page 287
Setting Up the Class......Page 289
Preparing a Game Level......Page 290
Main Game Events......Page 291
Player Controls......Page 293
Ending Levels and the Game......Page 295
Timeline Scripts......Page 296
Modifying the Game......Page 297
8. Casual Games: Match Three and Collapsing Blocks......Page 298
Reusable Class: Point Bursts......Page 299
Developing the Point Burst Class......Page 300
Using Point Bursts in a Movie......Page 304
Playing Match Three......Page 307
Game Functionality Overview......Page 308
The Movie and MatchThree Class......Page 309
Setting Up the Grid......Page 310
Player Interaction......Page 313
Animating Piece Movement......Page 316
Finding Matches......Page 318
Finding Possible Moves......Page 322
Score Keeping and Game Over......Page 325
Modifying the Game......Page 326
New! Collapsing Blocks......Page 327
Setting Up the Graphics......Page 328
Starting the Game......Page 329
Recursion......Page 331
Recursive Block Removal......Page 333
Falling Blocks......Page 336
Checking for Empty Columns......Page 337
Game Over......Page 339
Modifying the Game......Page 340
9. Word Games: Hangman and Word Search......Page 342
ActionScript 3.0 String Handling......Page 343
Applying Text Formatting to Text Fields......Page 347
Setting Up the Hangman......Page 354
The Hangman Class......Page 355
Development Strategy......Page 358
Defining the Class......Page 360
Creating the Word Search Grid......Page 361
User Interaction......Page 365
Dealing with Found Words......Page 368
Modifying the Game......Page 371
10. Questions and Answers: Trivia and Quiz Games......Page 372
Understanding XML Data......Page 373
Importing External XML Files......Page 375
Trivia Quiz......Page 377
Setting Up the Movie......Page 378
Setting Up the Class......Page 379
Message Text and Game Button......Page 382
Moving the Game Forward......Page 384
Displaying the Questions and Answers......Page 385
Judging the Answers......Page 387
Ending the Game......Page 388
Adding a Time Limit......Page 389
Adding Hints......Page 392
Adding a Factoid......Page 394
Adding Complex Scoring......Page 395
Randomizing the Questions......Page 397
Better Answer Arrangement......Page 398
Creating Loader Objects......Page 400
Determining the Right Answer......Page 401
Expanding the Click Area......Page 402
Images for Questions......Page 403
Modifying the Game......Page 404
11. Action Games: Platform Games......Page 406
Level Design......Page 407
Designing the Class......Page 414
Planning Which Functions Are Needed......Page 415
Class Definition......Page 416
Starting the Game and Level......Page 417
The Main Game Loop......Page 422
Character Movement......Page 424
Scrolling the Game Level......Page 429
Checking for Collisions......Page 430
Enemy and Player Death......Page 431
Collecting Points and Objects......Page 433
Showing Player Status......Page 434
The Game Dialog Box......Page 435
Modifying the Game......Page 437
12. Game Worlds: Driving and Racing Games......Page 438
Creating a Top-Down World......Page 439
Game Design......Page 442
The Class Definition......Page 445
The Constructor Function......Page 447
Placing the Trash......Page 449
Keyboard Input......Page 451
The Game Loop......Page 452
Moving the Car......Page 453
Checking for Trash and Trashcan Collisions......Page 456
The Score Indicators......Page 458
Game End......Page 459
Racing Game Elements......Page 460
Making the Track......Page 461
Constants and Variables......Page 463
Starting the Game......Page 464
The Main Game Loop......Page 465
Car Movement......Page 467
Checking Progress......Page 469
The Countdown and the Clock......Page 470
Modifying the Game......Page 472
New! 13. Card Games: Higher or Lower, Video Poker, and Blackjack......Page 474
Creating the Deck......Page 475
Setting Up the Class......Page 476
Starting the Game......Page 477
Responding to Player Moves......Page 479
Cleaning Up......Page 480
Video Poker......Page 481
Shuffle Up and Deal......Page 482
Making the Deck......Page 483
Game Elements......Page 484
Setting Up the Class......Page 485
Shuffling the Cards......Page 487
Timed Events......Page 488
Here’s the Deal......Page 489
Drawing Cards......Page 491
Finishing a Hand......Page 493
Calculating Poker Winnings......Page 494
Blackjack......Page 495
Setting Up the Class......Page 496
Starting the Game......Page 498
Timed Events......Page 499
Dealing Cards......Page 500
Hit or Stay......Page 501
Calculating Blackjack Hands......Page 503
Other Game Functions......Page 505
Modifying the Game......Page 506
New! 14. 3D Games: Target Practice, Racing Game, and Dungeon Adventure......Page 508
Setting 3D Positions......Page 509
Rotating Objects......Page 510
Game Elements......Page 512
Starting the Game......Page 514
Drawing the Cannon and Target......Page 516
Firing the Cannonball......Page 517
Modifying the Game......Page 518
3D Racing Game......Page 519
Setting Up the Movie......Page 520
User Control......Page 523
Player Movement......Page 525
Z-Index Sorting......Page 526
Modifying the Game......Page 527
Game Elements......Page 528
Setting Up the Game......Page 529
Constructing the Dungeon......Page 530
Main Game Function......Page 533
Player Movement......Page 534
Collecting Coins......Page 536
Extending the Game......Page 537
New! 15. Building Games for the iPhone......Page 540
What You Need......Page 541
Publishing for iOS......Page 543
The iOS Game-Building Process......Page 547
Screen Size......Page 548
Touch......Page 549
Accelerometers......Page 550
Adjusting the Screen Size......Page 552
Including the Image......Page 553
Publishing......Page 554
Setting Up the Class......Page 555
Starting the Game......Page 556
Game Play......Page 558
Collision Detection......Page 559
Modifying the Game......Page 561
Use the GPU and Bitmap Caching......Page 562
Simplifying Events......Page 564
Minimizing Screen Redrawing......Page 565
More Optimization Techniques......Page 566
Beyond the iPhone......Page 568
A......Page 570
C......Page 572
D......Page 575
E......Page 576
F......Page 577
G......Page 579
H......Page 582
L......Page 583
M......Page 584
N......Page 585
P......Page 586
Q......Page 587
S......Page 588
T......Page 590
U......Page 591
Z......Page 592