I am having a little bit of an issue with my brick breaker coursework game. I am trying to make the game produce bricks by using an array however I have ran into a little bit of an error of "array required, but java.util.List found".
Can anyone help?
Class that I am having trouble with:
public void createGameObjects()
{
synchronized( Model.class )
{
ball = new GameObj(W/2, H/2, BALL_SIZE, BALL_SIZE, Colour.RED );
bat = new GameObj(W/2, H - BRICK_HEIGHT*1.5f, BRICK_WIDTH*3,
BRICK_HEIGHT/4, Colour.GRAY);
bricks = new ArrayList<>();
bricks[0] = new GameObj(0,0, BRICK_HEIGHT, BRICK_WIDTH, Colour.BLUE);
}
}
The error is occurring on the bottom line:
bricks[0] = new GameObj(0,0, BRICK_HEIGHT, BRICK_WIDTH, Colour.BLUE);
Thank you
ArrayList
is not an array, but you try to usebricks
as an array. - Mark Rotteveel