Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

get sprites under mouse or pointer


glantucan
 Share

Recommended Posts

Hi

I'm developing a drag and match game and needed to get the sprite under the pointer when the drag stops.

I've seen other people use overlap between the dragged sprite and the target sprite, but this won`t work in my game as the dragged sprite can overlap with several targets at the same time.

So after some head scrapping I came out to this solution:

function wordDragStop (word, pointer) {	var success = Phaser.Rectangle.containsPoint(imgs[word.name].getBounds(),pointer.position);	if(success) {		console.log('Oh yeah!!!');	} else {		console.log('You failed miserably!');	}}

Which works fine.

 

I'm just wondering if there's a better way without having to store references of the sprites in an object.

 

Thanks in advance

 

 

Link to comment
Share on other sites

Hi tips4design

 

Thanks, but it doesn't work. Perhaps phaser can't detect the over event on other sprites as the pointer is actually over the dragged one, and this one is just bellow it.

 

Am I right?

Been looking for a way to do that for my inspector plugin, no luck :) will need to manually do it;

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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