QuentinIcky Posted January 24, 2017 Share Posted January 24, 2017 Hi all ! I'm new to phaser, I would like to create an event when items collide to the ground. The items are generated randomely. //Add items emails = level2.add.group(); emails.enableBody = true; emails.physicsBodyType = Phaser.Physics.ARCADE; //Generate items for (var y = 0; y < 2; y++) { for (var x = 0; x < 10; x++) { var mail = emails.create(5 + x * 94, y * 10, 'email'); mail.name = 'mail' + x.toString() + y.toString(); // ?? mail.checkWorldBounds = true; mail.events.onOutOfBounds.add(mailOut, this); mail.body.velocity.y = 150 + Math.random() * 200; } } I tried this : //Create collision level2.physics.arcade.overlap(ground, emails, fbiCollect, null, this); //enemy collect function enemy() { console.log('in enemy collect') mail.kill(); scoreEnemy += 10; } But it doesn't work.. So if anyone has an idea Link to comment Share on other sites More sharing options...
FinalFantasyVII Posted January 25, 2017 Share Posted January 25, 2017 Hi! Try this: //Create collision level2.physics.arcade.overlap(ground, emails, fbiCollect, null, this); //enemy collect function enemy(ground, mail) { console.log('in enemy collect'); mail.kill(); scoreEnemy += 10; } I hope it helps! Link to comment Share on other sites More sharing options...
QuentinIcky Posted January 26, 2017 Author Share Posted January 26, 2017 Thanks for your answer. Yes I already tried that, but unfortunately it doesn't work. Link to comment Share on other sites More sharing options...
QuentinIcky Posted January 26, 2017 Author Share Posted January 26, 2017 I finally succeeded by another way. I added a group of enemies under the character , and made them able to collect falling objects. The collision between them works well. Link to comment Share on other sites More sharing options...
Recommended Posts