mdix

Collision (Tiled & multiple layers)

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

Share this post


Link to post
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).

Share this post


Link to post
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

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.