Jump to content

How to detect collisions while dragging a sprite?


Mario
 Share

Recommended Posts

Hi,

 

is it possible to check if a sprite collides with others while dragging it?

 

I am trying to build a game where you can rearange items, but physics/collision detection seems to be deactivated for the dragged sprite. Therefore items will overlap. I need a solution to prevent overlapping. Anything included in Phaser?

 

So far I tried this:

game.physics.collide(group, group);

It works as expected for falling items, but not while dragging.

 

Thank you

Mario

Link to comment
Share on other sites

I would use game.physics.overlap() instead and then you'll need to handle what happens if they do overlap yourself really. Collide is meant to work across body motion, of which a sprite doesn't currently have any while being dragged. When we integrate p2.js later on you'll finally be able to do this though, but not yet.

Link to comment
Share on other sites

  • 1 month later...

I would use game.physics.overlap() instead and then you'll need to handle what happens if they do overlap yourself really. Collide is meant to work across body motion, of which a sprite doesn't currently have any while being dragged. When we integrate p2.js later on you'll finally be able to do this though, but not yet.

 

when will you integrate p2.js ? 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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