Jump to content

Phaser Collision Best Method?


Xron
 Share

Recommended Posts

Hi

 

So I'm planning on creating a big tile map, I was wondering what you think the best method of collision handling is. Before I would collide with all tiles apart from those in an array? I'm thinking now because this would be such a big map to have all my collision tiles on a layer in tiled? Does colliding with a lay work well?

Sam

Link to comment
Share on other sites

might be worth taking a look here

http://phaser.io/examples/v2/tilemaps/map-collide

 

looks like the collision is between certain tile types (by index) in the TileMap ?

 

edit: actually that's what you were already doing? I understand what your asking therefore is it better performance to have all collidable tiles in a separate layer? sorry I don't know the answer to that one.

 

j

Link to comment
Share on other sites

This is the biggest map in my game and it works fine on a Moto G xt1032 as long as it's the only layer. Having more than one layer also works fine on desktop, but the performance starts suffering on mobile. I'm colliding the character sprite against the tile layer, and swapping a big amount of tiles every second. 

 

Putting all collidable tiles on a separate layer and rendering it would probably be slower, since I think each layer will be a separate draw call.

 

If you use setCollisionByExclusion phaser will calculate the faces that collide only once, so it doesn't matter how big the exclusion array is. 
https://github.com/photonstorm/phaser/blob/v2.4.3/src/tilemap/Tilemap.js#L887

 

XVvooT9.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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