tru#_beast Posted June 28, 2017 Share Posted June 28, 2017 Hi im having a problem where only one out of my 15 sprites in my group are colliding and I dont know how to fix this. collisionDetection: function(){ this.game.physics.arcade.collide(this.player, enemy); }, //when they are being created for(var i = 0; i< this.ENEMY_SERVICE_POOL; i++){ enemy = new TGA.RunClasses.Enemy(this.game, { x:-20 + Math.random() * 500, y:0, origScale:this.gameConfig.ENEMY_SCALE, }); enemy.checkWorldBounds = true; enemy.outOfBoundsKill = true; this.enemyPool.push(enemy); console.log("kk"); this.gameLayer.add(enemy); } Idk why this happens. :l Link to comment Share on other sites More sharing options...
end3r Posted June 29, 2017 Share Posted June 29, 2017 Your collision detection only checks for the last one created - try colliding with the whole group of enemies: this.game.physics.arcade.collide(this.player, this.enemyPool); Link to comment Share on other sites More sharing options...
espace Posted June 30, 2017 Share Posted June 30, 2017 Is the collision detection with group better in term of performance ? Link to comment Share on other sites More sharing options...
end3r Posted June 30, 2017 Share Posted June 30, 2017 It's not about performance but the functionality you want to achieve. You can do the collisions manually with every single enemy, or do it a lot easier with the Phaser's built in functionality with groups - from the game's point of view you're doing exactly the same. Link to comment Share on other sites More sharing options...
Recommended Posts