Simple QuickBox2D Test
blog.tuncays.com
@author TUNCAYS
/**
* Copyright TUNCAYS ( http://wonderfl.net/user/TUNCAYS )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gPQu
*/
package
{
import com.actionsnippet.qbox.*;
import com.actionsnippet.qbox.objects.BoxObject;
import com.actionsnippet.qbox.objects.CircleObject;
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.net.*;
import flash.text.*;
import flash.ui.*;
/**
* blog.tuncays.com
* @author TUNCAYS
*/
public class Q2D extends MovieClip
{
private var sim :QuickBox2D;
public function Q2D():void
{
sim = new QuickBox2D(this);
sim.createStageWalls( { fillColor:0, fillAlpha:.2 } );
stage.frameRate = 60;
sim.grid(10, 0, .1);
sim.setDefault({fillColor:0x336655, lineAlpha:0, radius:1.5});
sim.addBox( { width:8, height:.1 , x:6, y:11.3,density:13.1 } );
var box:QuickObject = new BoxObject(sim,{y:3.5,width:5,height:.3,fillColor:0xFF0000,density:10});
var circle:CircleObject = new CircleObject(sim,{x:1,y:4,radius:.5,fillColor:0,density:.02,friction:0.0});
var circle2:CircleObject = new CircleObject(sim,{x:5,y:4,radius:.5,fillColor:0x118811,density:.02,friction:0.0});
sim.addGroup( { objects:[box, circle, circle2] } );
sim.addPoly( { x:12, y:8, verts:[[0, 0, 2, 2, 0, 2], [0, 0, 0, 1, -2, -0.2]], fillColor:0x0000FF } );
sim.addPoly( { y:10.85,x:5, verts:[[0, 2, 1, .4, 2, 2]], fillColor:0xFF0000 } );
sim.mouseDrag();
stage.addEventListener(MouseEvent.MOUSE_DOWN, stageStartHandler);
}
private function stageStartHandler(e:MouseEvent):void
{
sim.start();
}
}
}