• Create Account

### #ActualCornstalks

Posted 01 September 2012 - 07:04 PM

What's your problem? BRICKBOUNDS.remove(i) will remove the ith item.

Or perhaps you're wondering how to do it while still iterating over each item? In which case, don't increment i when you remove (something like this):
       for(int i = 0; i < BRICKBOUNDS.size();)
{
if(ballRectangle.intersects(BRICKBOUNDS.get(i)))
{
ball.yspeed = -ball.yspeed;
BRICKBOUNDS.remove(i);
}
else
{
++i;
}
}


### #2Cornstalks

Posted 01 September 2012 - 07:02 PM

What's your problem? BRICKBOUNDS.remove(i) will remove the ith item.

Or perhaps you're wondering how to do it while still iterating over each item? In which case, don't increment i when you remove (something like this):
       for(int i = 0; i < BRICKBOUNDS.size();)
{
if(ballRectangle.intersects(BRICKBOUNDS.get(i)))
{
ball.yspeed = -ball.yspeed;
BRICKBOUNDS.remove(i);
}
else
{
++i;
}
}


### #1Cornstalks

Posted 01 September 2012 - 07:02 PM

What's your problem? BRICKBOUNDS.remove(i) will remove the ith item.

Or perhaps you're wondering how to do it while still iterating over each item? In which case, don't increment i when you remove (something like this):
       for(int i = 0; i < BRICKBOUNDS.size();)
{
if(ballRectangle.intersects(BRICKBOUNDS.get(i)))
{
ball.yspeed = -ball.yspeed;
BRICKBOUNDS.remove(i);
}
else
{
++i;
}
}


PARTNERS