[casual_games] Game Development in AS3

Chris Cowherd chris at chriscowherd.com
Tue Nov 27 13:32:02 EST 2007


Ya AS3 is certainly different but clearly a better development language.

Off the top of my head, I would create create a set of classes something
like below. I'm quite sure I'm missing something but its a start :)

AircraftMgr
Singleton responsible for spawning Aircraft classes. Initializes them with
their spawn location, speed and keeps an array of all spawned and visible
aircraft. Be sure to use the [ArrayElementType] metatag over the array for
type safety (not many people know about it). This class is also responsible
for periodically choosing an active Aircraft and telling it to fire.

Aircraft extends Sprite
Responsible for its visual appearance, probably through the [Embed] metatag.
Maintains properties for the aircraft such as speed, position, damage.
Responsible for updating its position based on speed property. Various
types of aircraft can inherit from this class requiring various amounts of
damage to destroy or having different speeds, visual appearance etc. Has a
"fire" method that spawns an appropriate Projectile class through the
ProjectileMgr: ProjectileMgr.spawn( this, Bomb );

ProjectileMgr
Singleton responsible for spawning projectiles and keeping an array of
active and inactive projectiles (for efficiency). Spawn method can take two
parameters to know what type to spawn and from whom:
function spawn( source:Sprite, projectile:Class ) :void

For instance:
ProjectileMgr.spawn( aircraftRef, Bomb );

Projectile extends Sprite
Just like the Aircraft class. Projectiles inherit from this generic class.
For instance, class Bomb extends Projectile

CollisionMgr
Singleton responsible for checking for collisions between two types of
sprites. Having a separate class check for collisions can help reduce
redundant collision checks between sprites. It references the AircraftMgr,
ProjectileMgr and the gun / player. Has a method that takes two type
references to register collisions for. If two sprites have collided, it can
check the types to see if it should do anything (fire an event).
For instance lets say the function signature looks like this:

function addCollision( type1:Class, type2:Class ):void

You could call it like this:
CollisionMgr.addCollision( Bomb, Gun );
CollisionMgr.addCollision( Aircraft, Missile );


Obviously you need some more stuff here but I think you see the direction
I'm taking.

Good luck!

- Chris


On 11/26/07, dayvid jones <dayvid at dayvid.com> wrote:

>

> In AS3 how does a movie clip reference or find another movieclip?

> Example, let's say I have a game that has enemy airplanes and the

> play uses a gun to shoot them down, the airplanes are randomly

> selected and addchild is used to place them in the DisplayObject on

> the stage by the document class. Now lets say that the airplanes drop

> bombs, so the airplanes have their own class linked to the airplane

> movie clips in the library, this class uses a timer to drop bombs by

> using addchild and moves the plane. The bombs have their own class

> that move them down the screen and do a hittest looking for the

> players gun. How do you do this in AS3? In AS2 I would use a _root to

> allow the Bomb class to find the Gun MC. So in AS3 how do classes

> find MCs on the stage?

>

> Is my approach totally off for AS3? I'm trying to migrate from AS2

> game development to AS3, and my biggest problems is the DiplayObject ; (

>

> Does anyone know of a book or website that gives instruction or

> examples for a game with enemies that shoot back? Or can anyone

> answer my question?

>

> ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

>

> D A Y V I D J O N E S

>

> "Spock has a beard!?

> Dude, we are totally in the wrong universe..."

>

> Free Games, Free Music, Cool Photos and Documentaries!

> http://www.dayvid.com

>

> ...shouldn't you be listening to Calico Radio?

> http://www.CalicoRadio.com

>

> music for the mAdNeSs!

> http://www.DJGecko.com

>

>

>

>

>

>

>

>

>

>

>

>

> _______________________________________________

> Casual_Games mailing list

> Casual_Games at igda.org

> http://www.igda.org/casual-subscribe

> Archive: http://www.igda.org/casual-subscribe

> Archive Search:

> http://www.google.com/coop/cse?cx=010373383720242846960%3Az3tdwggxil8

> List FAQ:

> http://www.igda.org/wiki/index.php/Casual_Games_SIG/Casual_Games_List_FAQ

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://seven.pairlist.net/pipermail/casual_games/attachments/20071127/8887db70/attachment.html>


More information about the Casual_Games mailing list