Jump to content

Sprite vs Group: Any performance benefits to using group to check collisions vs sprites?


terencechow
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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