Note that there are some explanatory texts on larger screens.

plurals
  1. POEnemy Spawning Android
    primarykey
    data
    text
    <p>I am making an android game that spawns enemy sprites at a certain interval at the top of the screen. There are no syntax errors, but when I run the game it crashes because of this function:</p> <pre><code>public void updateEnemies() { if (numEnemiesCreated == numVisibleEnemies) { if (timeLastCreatedEnemy + 1000 &lt; System.currentTimeMillis()) { timeLastCreatedEnemy = System.currentTimeMillis(); boolean createdNewEnemy = false; for (int i = 0; i &lt; this.numVisibleEnemies; i++) { if (createdNewEnemy == false) { if (holderEnemy[i].isDisposed()) { this.generateNewEnemy(i); createdNewEnemy = true; } } } } for(int i = 0; i&lt;numVisibleEnemies; i++){ if(!holderEnemy[i].isDisposed()){ holderEnemy[i].move(); } } } else { holderEnemy[numEnemiesCreated] = new Enemy(context, 0, 0); numEnemiesCreated++; } } </code></pre> <p>I have tried everything, I just can't get it to work! Here is my log cat crash report:</p> <pre><code>05-25 18:49:13.031: W/dalvikvm(6736): threadid=9: thread exiting with uncaught exception (group=0x40015578) 05-25 18:49:13.035: E/AndroidRuntime(6736): FATAL EXCEPTION: Thread-10 05-25 18:49:13.035: E/AndroidRuntime(6736): java.lang.NullPointerException 05-25 18:49:13.035: E/AndroidRuntime(6736): at com.jlennon.gametest.EnemySpawn.updateEnemies(EnemySpawn.java:49) 05-25 18:49:13.035: E/AndroidRuntime(6736): at com.jlennon.gametest.MainGamePanel$AnimationThread.update(MainGamePanel.java:94) 05-25 18:49:13.035: E/AndroidRuntime(6736): at com.jlennon.gametest.MainGamePanel$AnimationThread.run(MainGamePanel.java:61) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload