Hashasm Posted March 21, 2017 Share Posted March 21, 2017 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 Quote Link to comment Share on other sites More sharing options...
Parasyte Posted March 22, 2017 Share Posted March 22, 2017 What are you trying to do with it? Everything is draggable *and* droppable? How do you resolve ambiguities when dragging two objects into each other simultaneously with multitouch inputs? Quote Link to comment Share on other sites More sharing options...
Hashasm Posted March 22, 2017 Author Share Posted March 22, 2017 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. Quote Link to comment Share on other sites More sharing options...
obiot Posted March 23, 2017 Share Posted March 23, 2017 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 : https://github.com/melonjs/melonJS/blob/master/src/level/TMXTiledMap.js#L463-L465 Quote Link to comment Share on other sites More sharing options...
Hashasm Posted March 27, 2017 Author Share Posted March 27, 2017 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 Quote Link to comment Share on other sites More sharing options...
Parasyte Posted March 28, 2017 Share Posted March 28, 2017 You only have a few options for saving; Save and load from localStorage; melonJS provides a wrapper for this. 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. Quote Link to comment Share on other sites More sharing options...
Hashasm Posted March 28, 2017 Author Share Posted March 28, 2017 hmm thank you , saving in local storage i got one example but I dont know how to start with option 2,how can i change my tmx /json directly suggest me some documentation or example to do the same Thank you Quote Link to comment Share on other sites More sharing options...
Parasyte Posted March 29, 2017 Share Posted March 29, 2017 It's going to be a DIY project. Here's the TMX spec: http://doc.mapeditor.org/reference/tmx-map-format/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.