Hi Raj,
I think I've managed to figure out the necessary logic! I've put the logic in my main class which is able to loop through each of the enemy instances as follows:
Code:
for(int i=0;i<enemy.length;i++) // Loop through each of the enemies and update location
{
enemy[i].original_x = enemy[i].x; // Set the current co-ords in case we need to move sprite back
enemy[i].original_y = enemy[i].y;
enemy[i].moveEnemyX(); // Call the enemy.moveEnemyX() method
for(int j=0;j<enemy.length;j++) // loop through each of the enemy instances and check for collision
{
if ((enemy[i].sprite.collidesWith(enemy[j].sprite, false)) & (i != j)) // Ignore collision with self
{
enemy[i].x = enemy[i].original_x;
}
}
}
I then have a enemy.movey method and do use the same logic to check for a collision between enemies after moving the Y-Co-ords and this seems to work ok.
Thanks for your help. Please let me know if you can think of a better way to do it but I think this should allow for efficient collision detection between multiple sprites.
Phil