Jump to content

does Phaser use a spatial structure to optimize physics ?


stopviolence
 Share

Recommended Posts

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...