protected void animate(
final Sprite sprite,
final SpriteRender spriteRender,
final int ballSize, final int ballIndex, final int batchSize, final int delta
) {
final float ballRadius = ballSize * 0.5f;
final float boundW = SCREEN_WIDTH - ballRadius;
final float boundH = SCREEN_HEIGHT - ballRadius;
final Sprite[] sprites = sprite.asArray();
final SpriteRender[] spritesRender = spriteRender.asArray();
for ( int b = ballIndex, r = 0, len = (ballIndex + batchSize); b < len; b++, r++ ) {
float x = sprites[b].x;
float dx = sprites[b].dx;
x += dx * delta;
if ( x < ballRadius ) {
x = ballRadius;
sprites[b].dx = -dx;
} else if ( x > boundW ) {
x = boundW;
sprites[b].dx = -dx;
}
sprites[b].x = x;
float y = sprites[b].y;
float dy = sprites[b].dy;
y += dy * delta;
if ( y < ballRadius ) {
y = ballRadius;
sprites[b].dy = -dy;
} else if ( y > boundH ) {
y = boundH;
sprites[b].dy = -dy;
}
sprites[b].y = y;
spritesRender[r].x = x;
spritesRender[r].y = y;
}
}