Jump to content

Collision (Tiled & multiple layers)


mdix
 Share

Recommended Posts

Hi,

 

first of all: Thank you very much for Phaser! Its just great how much work you keep away and how much fun you give to the developer.

 

I just have a brief question:

 

I built a map with Tiled. The map has 3 layers. The third layer contains the elements the 'player' has to collide with. I loaded the map via tilemap() and added a player sprite via sprite(). Both are displayed, everything works fine. I used 'setCollisionRange' to the tile numbers that occur in layer3 (the colission layer) and in my update() method I call (game.physics.collide(player, map)).

 

I checked my code twice and, concerning the colission, it does exactly the same thing as starstruck (examples/games/starstruck.php). The only difference I found was that the starstruck tilemap (assets/games/starstruck/level1.json) has only one layer. Is multiple layer collision detection implemented at present? If so, what am I doing wrong?

 

Thanks for your trouble and kind regards

Marc

Link to comment
Share on other sites

Hi rich,

 

thanks for your answer. How can I tell phaser which layer is my collision layer, or is it the first / last layer?

 

Kind regards

Marc

 

Edit: Ok, I checked the map obj. and it seems to be the last defined layer and it now works. Thank you very much.

Edit2: So there's just a short question: How can I get a specific layer to render after my player sprite has been rendered? Currently all three layers are rendered before the player object (the player object is above everything).

Link to comment
Share on other sites

Hi rich,

 

thanks for your help.

 

We need that feature really bad, because we need to place the sprite (character) behind other tiles. What do you think: When will this feature be available? We need to check if we can keep Phaser (and we would, because we love the community) or use another framework.

 

Kind regards

Marc

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
 Share

  • Recently Browsing   0 members

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