alright back to work lol
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
and now to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
now its saying the type im returning isnt a rectangle?
alright try again...
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } return randomBallRectangle; }[/source]
i made an object in the main game class Rectangle randomBallRectangle = getBallBounds();
the compiler shows no errors until i run it then i get this:
java.lang.NullPointerException
at game.getBallBounds(game.java:290)
at game.<init>(game.java:38)
Show differencesHistory of post edits
#4burnt_casadilla
Posted 13 August 2012 - 04:39 PM
alright back to work lol
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
and now to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
now its saying the type im returning isnt a rectangle?
alright try again...
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } return ???; }[/source]
this makes more sense so the loop isnt just automatically exiting. but idk what im returning to the arraylist
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
and now to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
now its saying the type im returning isnt a rectangle?
alright try again...
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } return ???; }[/source]
this makes more sense so the loop isnt just automatically exiting. but idk what im returning to the arraylist
#3burnt_casadilla
Posted 13 August 2012 - 03:39 PM
alright back to work lol
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
and now to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
now its saying the type im returning isnt a rectangle?
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
and now to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS.get(i).x, BALLS.get(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
now its saying the type im returning isnt a rectangle?
#2burnt_casadilla
Posted 13 August 2012 - 03:34 PM
alright back to work lol
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
Changed it to this
[source lang="java"] public Rectangle getBallBounds() { for(int i = 0; i < BALLS.size(); i++) { return new Rectangle(BALLS(i).x, BALLS(i).y, 20, 20); } Rectangle ballRectangle = getBallBounds(); }[/source]
so i will increase when the arraylist BALLS increases. but for some reason its saying BALLS(int) isnt a method when i want to call the ArrayList BALLS
#1burnt_casadilla
Posted 13 August 2012 - 03:16 PM
alright back to work lol
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array
i have this in my ball class
[source lang="java"] public Rectangle getBallBounds() { for(Ball ball : BALLS) return new Rectangle() }[/source]
this should return a rectangle every time one is created i think? besides the return method not being finished. i dont know how to call the coordinates of a ball in the array