I want to make only 20 spawn enemies, but i want there is a time delay in each spawn. What program should I make for this problem?
private int enemyCount = 20; private int enemySpawnTimer = -1; private int enemySpawnDelay = 180; // approx. 3 second time gap between spawns (currently constant) public void act() { if (enemyCount > 0) { enemySpawnTimer++; if (enemySpawnTimer%enemySpawnDelay == 0) { int x = 0; // make whatever x-coordinate you wish to spawn at int y = 0; // make whatever y-coordinate you wish to spawn at addObject(new Enemy(), x, y); enemyCount--; } } }