Hi all,
I wish to spawn my enemies again and again when they die or hit the target.
Also when the player is hit all spears should stop and not spawn anymore, and the player should be taken out and replaced with the player dead sprite.
Thank you
-shadowMoses
// My spears array, initiated also.
private Array<Spears> spears = new Array<Spears>();
// Drawn on the canvas, the location of the spears.
spears.add(new Spears(550, 270, 32, 11));
spears.add(new Spears(585, 282, 32, 11));
spears.add(new Spears(617, 294, 32, 11));
// update for the array, also delays the array for set time needed.
for (int i = 0; i < spears.size; i++) {
if (TimeUtils.nanoTime() - lastShot > shotFreq) {
spear1 = ths.get(i);
spear1.update(delta);
}
}
// Drawing/rendering on the screen.
for (int i = 0; i < spears.size; i++) {
spear1 = spears.get(i);
batcher.draw(AssetLoader.spearAnimation.getKeyFrame(runTime), spear1.getX(), spear1.getY(), spear1.getWidth(), spear1.getHeight());
}
// This is for the collision detection so the spear gets taken out when it hits the player.
for (int i = 0; i < spears.size; i++) {
spear1 = spears.get(i);
if (spear1.collides(monkey)) {
System.out.println("Spear Contact made");
batcher.draw(AssetLoader.hitAnimation.getKeyFrame(runTime, true), monkey.getX(), monkey.getY());
batcher.draw(AssetLoader.hitAnimation.getKeyFrame(runTime, true), monkey.getX() - 5, monkey.getY());
batcher.draw(AssetLoader.hitAnimation.getKeyFrame(runTime, true), monkey.getX() + 5, monkey.getY());
backgroundAnimation.stop();
spears.removeIndex(i);
i--;
batcher.draw(AssetLoader.monkeyDead, 185, 273);
break;
}
}
If anymore code is needed then I will provide.