stopviolence Posted March 16, 2016 Share Posted March 16, 2016 Hello. I gotta develop a side-scroll plateform game with a very large level and a lot of rectangular platforms. I need to know how phaser manages collision detection "inside the engine": 1 - does Phaser performs a stupid brute force test on each platform of the map ? so my game should eat too much cpu and i should use a tilemap instead of rectangular platforms 2 - does Phaser stores cleverly the platforms in a spatial structure (grid, kd-tree...) to make a local search before testing collision ? so i can use rectangular platforms Thanks for help Link to comment Share on other sites More sharing options...
rich Posted March 16, 2016 Share Posted March 16, 2016 Depends on the physics engine you use. p2 uses spatial management, yes. Ninja uses nothing. Arcade Physics uses a grid bounds spatial hash, which you can specify the sort direction of. Link to comment Share on other sites More sharing options...
stopviolence Posted March 17, 2016 Author Share Posted March 17, 2016 Thank you very much for information Do you know which spatial structure is used by p2 ? grid ? quadTree ? 2dTree ? Link to comment Share on other sites More sharing options...
stopviolence Posted March 17, 2016 Author Share Posted March 17, 2016 i read that in official docs: Phaser.Physics.Arcade - A light weight AABB based collision system with basic separation. Phaser.Physics.P2JS - A full-body advanced physics system supporting multiple object shapes, polygon loading, contact materials, springs and constraints. Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. Advanced AABB and Circle vs. Tile collision. Seems that ninja uses tile grid. It doesn't say anything about spatial structures in Arcade & P2 Link to comment Share on other sites More sharing options...
stopviolence Posted March 18, 2016 Author Share Posted March 18, 2016 I'm reading the doc, Seems that Arcade uses a quadTree. Link to comment Share on other sites More sharing options...
rich Posted March 18, 2016 Share Posted March 18, 2016 Arcade Physics has a quadtree, yes, but also the sortDirection property - this allows it to pre-sort collision groups based on a given direction, and then fast eliminate collision checks. Not much use if the scene is very dense, but extremely useful if your world is very wide or tall. Link to comment Share on other sites More sharing options...
Recommended Posts