glantucan Posted August 18, 2015 Share Posted August 18, 2015 HiI'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 More sharing options...
tips4design Posted August 18, 2015 Share Posted August 18, 2015 Asuming imgs[word.name] is a sprite:var success = imgs[word.name].pointerOver();I hope this is what you wanted. Link to comment Share on other sites More sharing options...
glantucan Posted August 19, 2015 Author Share Posted August 19, 2015 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? Link to comment Share on other sites More sharing options...
netcell Posted August 20, 2015 Share Posted August 20, 2015 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 More sharing options...
Recommended Posts