package
{
import flash.display.Sprite;
import flash.events.Event;
import nape.geom.Vec2;
import nape.phys.Body;
import nape.phys.BodyType;
import nape.shape.Polygon;
import nape.space.Space;
import nape.util.ShapeDebug;
/**
* ...
* @author Sp Games
*/
public class Main extends Sprite
{
public function Main():void
{
var space:Space = new Space(new Vec2(0, 600));
var debug:ShapeDebug = new ShapeDebug(600, 600, 0x333333);
addChild(debug.display);
var border:Body = new Body(BodyType.STATIC);
border.shapes.add(new Polygon(Polygon.rect(0, 0, -40, 600)));
border.shapes.add(new Polygon(Polygon.rect(600,0,40,600)));
border.shapes.add(new Polygon(Polygon.rect(0,0,600,-40)));
border.shapes.add(new Polygon(Polygon.rect(0, 600, 600, 40)));
border.space = space;
var block:Polygon = new Polygon(Polygon.box(50, 50));
var body:Body = new Body(BodyType.DYNAMIC);
body.shapes.add(block);
body.position.setxy(stage.stageWidth / 2, stage.stageHeight / 2);
body.space = space;
addEventListener(Event.ENTER_FRAME, function (_:Event):void {
debug.clear();
space.step(1 / stage.frameRate, 10, 10);
debug.draw(space);
debug.flush();
});
}
}
}
Thanks again guys.
Friday, October 14, 2011
Nape and Flash Develop - Tutorial 1: Hello Nape World
Hey guys,
Just made another movie for ya'll, this one is a implementation of the much lighter physics engine Nape, here it is!
Let me know your thoughts!
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment