bluecake Posted December 11, 2017 Share Posted December 11, 2017 Hello, Today I started with Phaser, I worked a lot at school with when I had free time. But I have a problem I can't delete an item in my group when my character makes a collision an item belonging to the group. make my group: (in create function) game.physics.startSystem(Phaser.Physics.ARCADE); game.physics.enable(character, Phaser.Physics.ARCADE); game.physics.enable(enemygroup, Phaser.Physics.ARCADE); enemygroup = game.add.group(); for(var i=0; i<10 ;i++) { var s = enemygroup.create(game.world.randomX, game.world.randomY, 'monster'); s.frame = 3; s.animations.add('enemymove', [2,3,4], 10, true); s.play('enemymove'); game.physics.enable(s, Phaser.Physics.ARCADE); } for detect collider:(in update function) game.physics.arcade.collide(character, enemygroup, function(){ enemygroup.remove(this); }); /*OTHER WAY I HAVE TRY*/ for(var i = 0; i < enemygroup.length; i++) { if(game.physics.arcade.collide(character, enemygroup)) { enemygroup.remove(enemygroup[i]); } } Thanks you for help ! good development at all and sorry for my bad english (i'm french). Link to comment Share on other sites More sharing options...
bluecake Posted December 12, 2017 Author Share Posted December 12, 2017 I fix problem with: function removeObject(item) { enemygroup.forEach(function(item){ if(game.physics.arcade.collide(character, item)) { item.kill(); } }); } Link to comment Share on other sites More sharing options...
Recommended Posts