terencechow Posted December 23, 2014 Share Posted December 23, 2014 I currently have about 5-10 enemies on screen at any given time. I track what's on screen with an array of these sprites. I'm wondering if my code would be more performant if I created the 5-10 enemies as a group and check for collisions? Right now I iterate through my array and have a sprite vs player check instead of doing a player vs group collision check. I need to eek out any bit of performance gain that I can get and I'm wondering if this will make a significant difference. Note that I am using arcade physics Link to comment Share on other sites More sharing options...
PMayhem Posted December 24, 2014 Share Posted December 24, 2014 Can't say I notice any performance difference, but I prefer using groups as it keeps the code looking tidy. I was pleasantly surprised with collision detection worked with groups.this.game.physics.arcade.collide(this.player, grpEnemies, this.playerEnemyCollide, null, this); playerEnemyCollide: function(player, enemy){ //Player Enemy Collision } } Link to comment Share on other sites More sharing options...
Recommended Posts