1 Replies - 1239 Views - Last Post: 10 March 2013 - 06:33 PM

#1 mouthwash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 12-February 13

nested for loop error

Posted 08 March 2013 - 11:23 PM

Hi
I am making a program to create a bunch of circles randomly on screen in android. This works perfectly fine, however when i add in detection for checking if circles overlap and chaning position if they do i get this error
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2110

Here is the code for making the points the circles will go too.
	private void makePoints(int amount) {
		// TODO Auto-generated method stub
		int distanceBetweenPoints;
		int distanceBetweenRadius;
		for (int i=0; i <= amount; i++ ){
			int XPos[] = {((int)(Math.random()*1000))};
			int YPos[] = {((int)(Math.random()*600))};
			if (i >= 0){
				for (int index=1; index <=i;index ++){
					distanceBetweenPoints = (XPos[0] - circleXPositions.get(index)[0]) * (XPos[0] - circleXPositions.get(index)[0]) * (YPos[0] - circleYPositions.get(index)[0]) *(YPos[0] - circleYPositions.get(index)[0]);
					distanceBetweenRadius = (radius *2) * (radius *2);
					if (distanceBetweenPoints < distanceBetweenRadius){
						XPos[0] = ((int)(Math.random()*1000));
						YPos[0] = ((int)(Math.random()*600));
					}
				}
			}
			circleXPositions.add(i,XPos);
			circleYPositions.add(i,YPos);			
		}

	}




this function is called in the "onCreate".

Is This A Good Question/Topic? 0
  • +

Replies To: nested for loop error

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,259
  • Joined: 27-December 08

Re: nested for loop error

Posted 10 March 2013 - 06:33 PM

Moved to Android.

Please post the entire stack trace.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1