Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created with IntelliJ IDEA.
- * User: VirtualMaestro
- * Date: 12.03.12
- * Time: 21:49
- * To change this template use File | Settings | File Templates.
- */
- package tests
- {
- import flash.display.Sprite;
- import nape.dynamics.InteractionFilter;
- import nape.geom.GeomPoly;
- import nape.geom.Vec2;
- import nape.phys.Body;
- import nape.phys.BodyType;
- import nape.phys.Material;
- import nape.shape.Polygon;
- [SWF(width=800, height=600, backgroundColor=0xdddddd, frameRate=30)]
- public class TestFiltering extends Sprite
- {
- static public const APP_WIDTH:int = 800;
- static public const APP_HEIGHT:int = 600;
- private var _core:InitNape;
- private var _frameRate:Number = 30;
- private var _timeStep:Number = 1 / _frameRate;
- public function TestFiltering(initNape:InitNape = null)
- {
- _core = initNape;
- if (_core == null)
- {
- _core = new InitNape(APP_WIDTH, APP_HEIGHT, _frameRate, 10);
- addChild(_core);
- }
- init();
- }
- private function init():void
- {
- var bigBoxCollisionGroup:int = 0x000000001;
- var bigBoxCollisionMask:int = 0x000000001;
- var triangleCollisionGroup:int = 0x000000011;
- var triangleCollisionMask:int = 0x000000001;
- var hexagonCollisionGroup:int = 0x000000001;
- var hexagonCollisionMask:int = 0x000000010;
- //
- var bigBox:Body = new Body(BodyType.DYNAMIC, new Vec2(APP_WIDTH/2, APP_HEIGHT-150));
- var bigBoxSize:int = 100;
- bigBox.shapes.add(new Polygon(Polygon.box(bigBoxSize, bigBoxSize), new Material(0.5), new InteractionFilter(bigBoxCollisionGroup, bigBoxCollisionMask)));
- bigBox.space = _core.space();
- //
- var triangle:Body = new Body(BodyType.DYNAMIC, new Vec2(APP_WIDTH/2, APP_HEIGHT-300));
- var triangleSize:int = 30;
- var vertices:GeomPoly = new GeomPoly();
- vertices.push(new Vec2(-triangleSize, -triangleSize));
- vertices.push(new Vec2(triangleSize, -triangleSize));
- vertices.push(new Vec2(triangleSize, triangleSize));
- triangle.shapes.add(new Polygon(vertices, new Material(0.5), new InteractionFilter(triangleCollisionGroup, triangleCollisionMask)));
- triangle.align();
- triangle.space = _core.space();
- //
- var hexagon:Body = new Body(BodyType.DYNAMIC, new Vec2(APP_WIDTH/2, APP_HEIGHT-400));
- var hexagonSize:int = 50;
- hexagon.shapes.add(new Polygon(Polygon.regular(hexagonSize, hexagonSize, 6), new Material(0.5), new InteractionFilter(hexagonCollisionGroup, hexagonCollisionMask)));
- hexagon.space = _core.space();
- // Static platform
- var platform:Body = new Body(BodyType.STATIC, new Vec2(APP_WIDTH/2, APP_HEIGHT-50));
- var polygonShape:Polygon = new Polygon(Polygon.box(APP_WIDTH, 50), new Material(0.5), new InteractionFilter(0xffffffff, 0xffffffff));
- platform.shapes.add(polygonShape);
- platform.space = _core.space();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement