Jump to content

Item id in .overlap()


Recommended Posts


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);






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

  • 1 year later...

  • Recently Browsing   0 members

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