Multi-Touch Water Simulation Example

Microsoft Surface has a cool simulation that allows you to drag your fingers across the table to create a water simulation. That got me to thinking about doing it in Flash. Thanks to David Lenaerts’ excellent Ripple class, it took me about 10 minutes to create the example below.

As you can see the performance is very nice. The code that I used to create this is below. Again, all of the cool stuff comes from David’s code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import be.nascom.flash.graphics.Rippler;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var t:Bitmap;
var r:Rippler;

t = new Bitmap(new bmap());
addChild(t);

r = new Rippler(t, 60, 6);

stage.addEventListener(TouchEvent.TOUCH_MOVE, handleMouseMove);

function handleMouseMove(e:TouchEvent):void
{
    r.drawRipple(e.stageX, e.stageY, 20, 1);
}

Lee

Show Comments

Hide Comments

Comments are closed.