collision-as3Â is a stand-alone broadphase collision detection library with its main focus on performance and developer experience. It has been explicitly designed to be independent of any physics simulation engine, and is intended for use on the gameplay level.
It has an object-oriented system and the collision management is made by objects through easy-to-extend Agent class. Some of its features include continuous and discrete collision detection, spatially partitioned containers (Quadtree and Spatial Hash Grid), generic bounding volume and Starling integration.
Sample
//Create spatial containers var quadtree : Quadtree = new Quadtree(new Volume(500.0, 500.0, 500.0)); var spatialHash : SpatialHash = new SpatialHash(); //Create two agents var agentA : Agent = new Agent(1, Mask.ALL, 50.0, 50.0, 10.0)); var agentB : Agent = new Agent(2, Mask.ALL, 80.0, 50.0, 10.0)); //Add agents to containers quadtree.addAgent(agentA); quadtree.addAgent(agentB); spatialHash.addAgent(agentA); spatialHash.addAgent(agentB); //Manipulate agents agentA.translate(7.5, 0.0); agentB.translate(-7.5, 0.0); //Handle collisions for each( var collision : Collision in spatialHash.queryCollisions() ) { //... } //Issue some aribtrary queries var queryA : Vector. = quadtree.queryVolume(new Volume(65.0, 50.0, 20.0)); var queryB : Vector. = spatialHash.queryPoint(new Volume(65.0, 50.0)); //Clean up quadtree.deleteAgent(agentA); quadtree.deleteAgent(agentB); spatialHash.deleteAgent(agentA); spatialHash.deleteAgent(agentB);