Flipping A BitmapData Image

September 2, 2010

Here’s a handy code snippet for flipping the pixels of a bitmapdata, and ending up with a new bitmap data that is the mirror image of the original.

function flipBitmapData(original:BitmapData, axis:String = "x"):BitmapData
{
     var flipped:BitmapData = new BitmapData(original.width, original.height, true, 0);
     var matrix:Matrix
     if(axis == "x"){
          matrix = new Matrix( -1, 0, 0, 1, original.width, 0);
     } else {
          matrix = new Matrix( 1, 0, 0, -1, 0, original.height);
     }
     flipped.draw(lanternArtSide, matrix, null, null, null, true);
     return flipped;
}

Usage is simple. Pass a reference of the original bitmapdata, and it will return a new bitmapdata that is a flipped version. It will not alter the original.

Flash Logo
You heard it here first. Flash Player is going to add OpenGL support in the next version. They will announce it at FOTB.
How do i know? Who is my secret inside source at Adobe?
I don’t. And Nobody. But it hit me like a bolt from the blue. They desperately need the increased graphics performance on both desktop and mobile devices, and they are seeing serious competition from Unity.
Watch this space to see if I’m really right.

This movie requires Flash Player 10

I’m a sucker for a good particle effect. They seem like magic to me and are one of the most fun parts of making a game. I recently stumbled upon a really efficient method for making a particle system that can render thousands of particles on screen while maintaining 30 frames per second more more.

I’ll give you complete source for the clock after the jump. Read the rest of this entry »

Want to make a cool physics-based Flash Game like Paper Cannon? Well the place to start is with a great free flash library called Box2D. There are a number of physics engines in flash, but Box 2D is pretty much the gold standard. The large number of developers working with it and the fact that the same library has been ported to a number of different languages (C++, Java, XNA, iPhone, Android) makes this a great choice.

But it also means that most of the tutorials to use it are either in the wrong language, or use an outdated version.

This tuturial uses AS3 and Box2D version 2.1a.

In this tutorial you will get your feet wet with Box2D, creating a world with some objects that collide in a real way. After that we will build out the example to make a game like Paper Cannon, in which you can use the Flash IDE as your level designer, just by dragging symbols around on the stage.

This movie requires Flash Player 10

This is an example of what we’re going to build.
Read the rest of this entry »

Holy cow! Mochigames just started a new featured game callout on their homepage, and guess whose game the decide to feature first? My new game Ghost!

Thanks Mochigames!