0
random nextInt
My game crashes after this line --> velX = (random.nextInt(10) - 5); any ideas?
4 Respostas
+ 5
According to the documentation, nextInt only throws an IllegalArgumentException if the parameter is not positive.
My guess is it that you are not calling it with a literal constant 5, but rather with some variable that happens to be zero (or negative).
The exception was being thrown from another call to r.nextInt() on the same line which was taking an uninitialized variable as an argument!
+ 3
What was the error?
+ 3
If what @Gawen said wasn't your problem,
I suggest using the debugger. Add some break points where it crashed and go through what the code is doing.
Make sure there's no infinite loops.
+ 1
"What was the error?"
Something with Thread...
game is running but when it's going to spawn mobs with this code it crashes.
what should I do?