dinsdag 15 maart 2011

making shards with BitmapData as3

Get Adobe Flash player

Playing around with BitmapData in flash and using the copyChannel on the alpha to create custom shards of a mc. You can provide a breakage pattern. This was used in a project where you had to smash avatar pictures of your friends in hyves.
Source is here. (flash cs3, as3)

Class for Physics Rigid Body with Sentries

There are many ways to do physics calculations, but in games you are always thinking about speed.
Physics calculations are generaly heavy calculations. Also most optimalizations require complex mathematical models to be created or limit the shapes you can actually collide.
One of the most elegant ways to do rigid body physics I ever found was one that used vertex-integration (like most) and a the concept of sentries.
Here you see how this looks:
First you make sure your movieclip rotates where most of the weight is. In this case a little bit more to the bottom.
Then you create a movieclip inside the object (the car), called 'perim' (for perimeter).
Along the perimeter you place sentries, empty movieclips (in this case they are small white squares) where you want your object to bounce.
Now for each move, you check if each of these sentries hit (with hitTestPoint) another movieclip.
The points find a way out of the bounce object and this influences the speed and rotational speed of the object.
It's that simple.
Here is a result and here are the sources.

donderdag 17 februari 2011

Flash detection of tilted face

The previous version wasn't all that accurate, allthough it was fast.
Now I've made a version that samples an image under a number of tilts and compares the results.
It turns out this is a very handy approach.

http://workinprogress.ludatic.nl/ludatic/facedetection/

I used the deface project as a basis, this is without the tilting offcourse, which as you can see, adds a lot of accuracy.
http://code.google.com/p/deface/

maandag 14 februari 2011

Face detection on 80x80 pixels

This was the question from a client, I wasn't sure after looking at some examples, so I created this test:
Go there

vrijdag 11 februari 2011

Buttons and mouse transparency

It's a wellknown fact by now, that using this:
this.mouseEnabled=false;
this.mouseChildren= false;
will prevent an object from receiving mouse-events, BUT.... So you can put buttons underneath something and still get your mouseevents..

I am creating the ludatic site as we speak in AS3 and came across the following.
I create a loader and load an overlayer from a file (for instance a menu).
The menu had a big transparant PNG.
Now the buttons on the page below didn't work anymore. Naturally, I had to
I could set this up differently, but I think you should be able to fix these things programmatically, without rethinking your designs or the way you build them up.
So I set the mouseEnabled and this.mouseChildren property in the document class. It still didn't work..

After a lot of scratching my head and staring at the wall with my head in my hands....

Offcourse: The loader is mouseEnabled, this is a default. The big transparent PNG is not enabled, but it is inside the loader.content, which is a display object and therefore receives (and blocks) mouseEvents.
So the idea is to set the loader to mouseEnabled=false (and it's children) and there you go..

donderdag 13 januari 2011

3d as2/as3

This used to be my prefered method to do 3D in flash:

I made layers in flash, which I scaled and stacked on top of each other and beveled for lighting. By rotating some and not all of the layers, I can even animate the top half of the liebherr.. Now with just 8Kb, you have a remarkably detailed 3d animatable model. You can only use them small and orthogonally, but the effect is quite nice and you have a lot of control over how a model looks. Also it's quite easy to do..
I am curious how the same model would look in true 3d in as3, so this is a challenge I'll get back to..

woensdag 12 januari 2011