Jump to content

collision detection between two entites


Recommended Posts

HI ,

can someone tell me how can I detect collision between two me.DraggableEntity  entites. or detecting collision between two sprites when they are dragging and dropping on each other.

we can detect the collision by using me.DroptargetEntity but when i make an entity as me.DroptargetEntity  then i cant able to drag the same please help me with this 

Thank You

Link to comment
Share on other sites

I am creating city building game in that from hud element  I am dragging and placing my house in a map,so user experience perspective if he tries to put a house over an exsisting house then i should say u can't place here(check for overlap or collision), so only I want to prevent being collide with each other. 

after dropping the house I am letting user to modify the house place i mean again in the game also use can drag his house anywhere he wants.

so please can you tell me how can I do the same.:mellow:

Link to comment
Share on other sites

you just need to add a entity with a body shape, at the same place of the house, and check for collision from or with that entity.

if you look at the melonJS source code, it's all we really we do  : create an entity with a body, and configure them as WORLD_SHAPE for the the collision layer  :


Link to comment
Share on other sites

finally i got it. i am creating entity with collision type .

but can you guys help me with this:-

now i am creating one new building in my game, when i am refreshing my browser that building disappearing i mean its not saving can someone tell me how to save my building at  that position only even when I refresh my building:rolleyes:

Link to comment
Share on other sites

You only have a few options for saving;

  1. Save and load from localStorage; melonJS provides a wrapper for this.
  2. Create an HTTP REST API to save and load from your favorite database ... or directly rewrite the TMX/JSON files

Option 2 is really cool if you are saving directly to the TMX/JSON files, but doing any of that is way outside of the scope of melonJS.

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...