// you’re reading...

ActionScript 3.0

AS3 Earthquake Class v1.0

I’ve noticed that there are a lot of small things that can save you time when designing and coding a game. Stuff that wouldn’t take long to code, but if someone’s already done it, why bother?

So in that glorious spirit of apathy, I present to you the Pixelwelders Earthquake class. This is just a simple little class that allows you to create an earthquake (or explosion, or invasion, or whatever) in your game. You just feed it a DisplayObject, the intensity of the quake, and the duration in seconds, and voilá. This is the syntax:

Earthquake.go( displayObject:DisplayObject, intensity:Number, seconds:Number ): void

And this is a two-line example:

import com.pixelwelders.fx.Earthquake;
Earthquake.go( gojira, 10, 1 );

And this is the result. Notice that each time you click, the earthquake is slightly different. Scroll down to download the class.

Download the class (and the above example) here.

Discussion

4 comments for “AS3 Earthquake Class v1.0”

  1. You sure love singletons.

    Posted by Benjamin | March 25, 2008, 11:41 am
  2. Well, I do love Singletons, but this is just a static class. It seemed easier to use that way.

    Posted by Zack Jordan | March 25, 2008, 3:12 pm
  3. Blast, I just assumed. I’ll download it now, and every piece of code from now on! Gotta catch ‘em all! Gotta catch ‘em all!

    Posted by Benjamin | March 27, 2008, 1:55 pm
  4. You’ve probably already got something that does this. I’ve just noticed that I always tend to make some sort of “screen shake” class for every game. This was just me making something reusable. It’s really not very complicated- just well-encapsulated.

    Posted by Zack Jordan | March 27, 2008, 4:43 pm

Post a comment

Twitterpated