Jump to content

Check if a Sprite Overlaps on A specific tile layer


Recommended Posts

I still struggling on overlap handler on phaser, I have this code on create function:

this.changelevel = this.map.createLayer("changelevel")this.map.setCollisionBetween(1,78, true,"changelevel")

and this code on update function:


the something property only returns console.log('lol'), and i expect it will only fire if the player sprites overlaps on the changelevel layer. But everytime i start the game, the callback function always fire. Please help me to understand the overlap method on a tilemap object.



Link to comment
Share on other sites

  • 1 month later...

I'm late but I hope this can help. I discovered this problem today.


The docs say for overlap : "Unlike collide the objects are NOT automatically separated or have any physics applied, they merely test for overlap results".


When you use

this.map.setCollisionBetween(1,78, true,"changelevel")

it's related to physics, and it's useful with collide, but overlap is not related to physics.


So, I think the test is "is the sprite overlapping on the whole layer (the screen) ?". The answer is always "yes".


One solution is to test overlapping between sprites. For example, you can find help to create sprites from json files here : https://gamedevacademy.org/html5-phaser-tutorial-top-down-games-with-tiled/.





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.

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.


  • Recently Browsing   0 members

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