universaljs Posted December 20, 2015 Share Posted December 20, 2015 I have a question, if I have something like this code: game.physics.arcade.overlap(player, group, function(player, item){//Can I get ID item object?}... in functions parametr is item (item this is children group)and can I get ID this object item? Link to comment Share on other sites More sharing options...
Toninio78 Posted December 21, 2015 Share Posted December 21, 2015 I think we have the same problem : http://www.html5gamedevs.com/topic/19374-i-cant-find-the-way-to-identify-each-dropzones-overlap-problem/ :wacko: Link to comment Share on other sites More sharing options...
drhayes Posted December 21, 2015 Share Posted December 21, 2015 I'm not sure what you're asking. The objects that overlap are passed to the collision handler, not the group. Link to comment Share on other sites More sharing options...
universaljs Posted December 21, 2015 Author Share Posted December 21, 2015 I have :group = game.add.group();and then: game.physics.arcade.overlap(player, group, function(player, item){//I want get smoething like this: console.log(item.id); //Is it possible?}, null, this); Link to comment Share on other sites More sharing options...
AzraelTycka Posted December 22, 2015 Share Posted December 22, 2015 I have :group = game.add.group();and then: game.physics.arcade.overlap(player, group, function(player, item){//I want get smoething like this: console.log(item.id); //Is it possible?}, null, this); Hello, I think you could use yourSprite.key or yourSprite.name. Check sprite class in phaser docs. Basically when you create your sprite and add it to your group you can name it and then go with item.name or you can use item.key if your logic allows it. Or just add id as your property to the sprite (yourSprite.id) - extend the class / just sprite object - and then go for item.id (though it's the same thing as using yourSprite.name). Well at least I think this should work, not sure if I got what you need properly? Link to comment Share on other sites More sharing options...
universaljs Posted December 22, 2015 Author Share Posted December 22, 2015 I foundgroup.getIndex(item);Thanks Link to comment Share on other sites More sharing options...
omsoms Posted November 7, 2017 Share Posted November 7, 2017 Hello friend, I'm new to using phaser, I also have that problem, take the ID of an item in a group, I see you have the solution, can you give an example of that code to understand it better?Thanks friend. Link to comment Share on other sites More sharing options...
Recommended Posts