I’m just learning Java, and I am working with a GRect object. I’m trying to assign the x and y coordinates to an int, but not having luck. I’m not sure what I’m missing?
Specifically, I’m looking at the getHeight():
Basically, I’ve got
add(new GRect(moveRight,getHeight(), BRICK_WIDTH, BRICK_HEIGHT));
That is working fine, but I assigned getHeight to an int, and then it doesn’t work:
int displayHeight = getHeight();
add(new GRect(moveRight,displayHeight,BRICK_WIDTH,BRICK_HEIGHT));
Any ideas?
To clarify-from what I have gathered from these online classes, getHeight() will return the height of the graphics window if it isn’t assigned to a class.
With the above, I’m trying to get the GRect to start at the bottom of the graphics window…as I said, when having the first example above, the rectangles move correctly, in the second example, they remain at the top of the display.
Thanks!
Joel
The problem ended up being that I was not properly declaring the variable within the method. Thanks for all your help!