I'm using LibGDX to create a game, but I'm encountering a problem with SpriteBatch. Whenever two objects that use the same image for their sprite come onto the screen, the new object replaces the old object. So, for example, one ship will come onto the screen, and when a ship with the same sprite comes onto the screen, the old ship will disappear and the new ship will have all the damage and other characteristics of the old ship.
I could always make multiple copies of the same image and put them in the assets folder, but that seems unnecessary. Does anyone have any ideas? Am I using SpriteBatch incorrectly?
Edit: Here's a couple of examples of rendering methods in the game loop.
The method for rendering ships:
private void renderDoodad(Doodad doodad) {
if (!doodad.isDisabled()) {
batch.begin();
if (doodad instanceof Enemy) {
batch.draw(doodad.getSprite(), doodad.getX(), doodad.getY());
Followed by some code about what to do if the ship is the player's ship. But the player's ship is rendering fine, so I left that out.
Then there's the method for rendering shots:
private void renderShot(Shot shot) {
if (!shot.isDisabled()) {
batch.begin();
batch.draw(
shot.getSprite(),
shot.getX(),
moveDoodadY(shot, shot.getDirection().getVal()
* getApp().getGraphics().getDeltaTime()));
batch.end();
}
}