Tower Defense in AS3 - Part II

November 12th, 2008 | Category: Actionscript, Game Development

In this segment, we will be covering creep movement within a map, and to stay true with our original intent, everything in this tutorial will be drawn manually using the graphics package in the Sprite object within Flash. This way, we don’t have to worry about downloading images or the file size involved with such extras. Of course, were this a real TD game to be published, we would whip up some original artwork and animations to give our game a little more flair, but in this case, the simpler the better!

The code additions you can expect to find in Part II of this series include drawing our map (or “road”), creating and moving our creeps along that road and recognizing when a creep has completed the course successfully. Anyone familiar with Tower Defense games will recognize the importance of having a trigger to know when each creep finishes. Depending on the rules of your particular game, you may wish to have the creep run another circuit upon completion or simply vanish from existence, but in either case, there will be significant effects from that little guy getting away. Sometimes it costs us money to banish him back to the beginning, and in other games, we simply lose one of our lives and take one step closer to defeat.
Read more

8 comments

Tower Defense in AS3 - Part 1

October 28th, 2008 | Category: Actionscript, Game Development, Programming, Web Development

In keeping with my desire to learn as much about how the game development world works, I have spent some time looking into developing simple games in Flash over the course of the last couple years. Recently, I renewed my pursuit of this game medium, and I have been striving to learn some of the ins and outs of Actionscript 3. Having written a handful of basic Flash applications in Actionscript 2 — from the loader and controls of a full media presentation to an MP3 player and dynamic slideshow — I feel I had a solid understanding of the principles of Flash, both in the timeline, layering and scripting realms.

However, when I began working with AS3, whole worlds began to open up as I saw the potential unleashed by implementing a much more true OOP support into the code base. One of the most useful things that AS3 encourages is the understanding and use of the layering hierarchy of sprites and movie clips on the stage. As you add children to specific sprites or movie clips, they inherit their parent’s visibility spectrum and appear truly as part of that element on the stage. This may well have been a feature of AS2 as well, but I never took the time to learn that aspect deeply enough, since I did most of my work from modifying timeline animations.

I decided some time ago that one of the best ways to learn Flash would be to write a game that implements many of the features, such as vector layering and stage positioning. Furthermore, with my addiction to Tower Defense (TD) style games, I thought it only fitting to develop one myself and share my learning progress with others who may also be interested in the same type of application. This post is the first in a series that will follow my progress from manually drawing the GUI on which the game will be played (this post) to creating the basic Creeps and Towers which will make up the substance of the game. For those who are anxious to get started and don’t want to read everything in detail, I will provide a download link at the close of each post with the full source for the project to that point.
Read more

3 comments