Skip to content

Example – Hellicopter

November 14, 2006

This example is very cool, much better then the matrix I posted the other day.

Here is a link of the SWF. Sadly, I can’t embed SWF inside this blog, but this may be would be fix.

You can see there a square with a rotor inside…. a complex MovieClip. Control it with the arrow keys and press the red button whenever you die.

To build this kind of pretty complex behaviour, was pretty simple, ones I had all the material done. It was fun, but somewhat complex to build the Physics engine (comes with the framework) but after it was done, all the rest was putting the pices together.

Firs, I’ve created an extention for a MovieClipCommander, called “taxi” (Don’t ask me why, yet…) inside it was the managing of everything.

To get the hpysics working, all I had to do is register the VectrForce extention, witch is the extention that simulate forces of vectors, to the MovieClipCommander that the Taxi was responsibble for:

__force = VectorForce(__commander.registerExtention(“force”, VectorForce));
__sides = __force.addForce(“sides”, 90, 0);
__up = __force.addForce(“up”, 0, 0);
__force.addForce(“gravity”, 180, 98);

Now all needed to do is to listen to the keyboard and when pressing the “up arrow” key, set the module (force) of “__up” to a high value that will resist gravity:

To get the feeling of swinging to the direction, I used the simple “ease” just to ease the rotation to -5 or 5:

__ease = Ease(__commander.registerExtention(“ease”, Ease));
function turn(accel:Number) {
  __sides._module = accel;
  __ease.easeProperty(“_rotation”, 5 * (accel / Math.abs(accel)), 4);

Now I’ve created an extention for a complex hit detection (scans defined movieclips around the main movieclip and keeps their coordinates). So to use it, all I had to do is register it:

__hit = BoundsDetector(__commander.registerExtention(“hits”, oundsDetector));
__hit._mcForTest = _root.wall;
__hit.mapMovieClip(“hits”, “hit”);

And to wrao it up, just listen to the events I want and handle them:

__commander.addEventListener(BoundsDetector.EVT_HIT_DETECTED, this);
__commander.addClipEvent(“onEnterFrame”, this);

That all! Everything is working together, but idependently to create a complex behaviour that none of the extention by itself could (or should have) done.

The project (for Flash Develop) can be downloaded from This Link.

As always, your feedback meens allot to me. Please tell me things… 🙂

One Comment
  1. Links is broken, IAP

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: