I am using this code to using a Random generator to generate random positions.
But i keep getting this error
11-06 21:33:07.364: ERROR/AndroidRuntime(12796): java.lang.IllegalArgumentException
11-06 21:33:07.364: ERROR/AndroidRuntime(12796): at java.util.Random.nextInt(Random.java:186)
Here is the code i am using.
private void addFace() {
Random rand = new Random();
float x = (int) roof.getHeight() + mBallTextureRegion.getWidth();
float minY = mBallTextureRegion.getHeight();
float maxY = (int)(roof.getHeight() - mBallTextureRegion.getHeight());
float rangeY = maxY - minY;
//The error points here
float y = rand.nextInt((int)rangeY) + minY;
That means that rangeY is negative. Check the logic that you’re using to assign that value.