I have a array of sprite in a class "Enemy", I want to draw enemies in some positions, but when I draw one, the previous one disappears.
public class Level1 implements Screen{
Vector2 position;
private Enemy enemies = new Enemy();
public Level1 (NameGame game){
this.game = game;
position = new Vector2(300,100);
enemies.nemici();
And this is my for loop:
for (i=0;i<enemies.enemy.size;i++){
//Maybe i need for (Sprite s : enemy)
game.batch.draw(enemies.enemy.get(i),position.x,position.y,100,100);
}
It's only a test to draw enemy, after i will try to draw in more position
If i change position.x and position.y every iteration, for example with position = new Vector2(..,..) after the "game.batch.draw", the previous enemy disappear, but why? How can i draw all?
And this is my enemy class:
package com.mygdx.game;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.utils.Array;
public class Enemy {
public Array<Sprite> enemy = new Array<Sprite>(14);
public void nemici() {
//Inizializzo e aggiungo i nemici all'array
Sprite mysterio, boss, doctorstrange, electro, goblin, ironman, lizard, mj, ned, octopus, rhyno, sandman, scorpion, scorpion2, venom;
enemy.add(mysterio = new Sprite(new Texture("mysterio.png")));
enemy.add(boss = new Sprite(new Texture("boss.png")));
enemy.add(doctorstrange = new Sprite(new Texture("doctorstrange.png")));
enemy.add(electro = new Sprite(new Texture("electro.png")));
enemy.add(goblin = new Sprite(new Texture("goblin.png")));
enemy.add(ironman = new Sprite(new Texture("ironman.png")));
enemy.add(lizard = new Sprite(new Texture("lizard.png")));
enemy.add(mj = new Sprite(new Texture("mj.png")));
enemy.add(ned = new Sprite(new Texture("ned.png")));
enemy.add(octopus = new Sprite(new Texture("octopus.png")));
enemy.add(rhyno = new Sprite(new Texture("rhyno.png")));
enemy.add(sandman = new Sprite(new Texture("sandman.png")));
enemy.add(scorpion = new Sprite(new Texture("scorpion.png")));
enemy.add(scorpion2 = new Sprite(new Texture("scorpion2.png")));
enemy.add(venom = new Sprite(new Texture("venom.png")));
}
}