I want to build a dx ball game. In my game, I want to draw a ball, a bar, bricks individually. It means when ball position is ready, the ball will draw; when bricks are ready bricks will draw. In the normal way, I lock surface holder then draw everything. Example:
@Override
public void run() {
while(ballPlay){
try{
gameCanvas = null;
gameCanvas = surfaceHolder.lockCanvas();
gameCanvas.drawColor(Color.WHITE);
ballPosition.drawBall(gameCanvas);
for (int i = 0; i < brickCount; i++) {
brick[i].drawBrick(gameCanvas);
}
gameBar.drawBar(gameCanvas);
}catch (Exception e){
e.printStackTrace();
} finally {
if(gameCanvas!=null){
surfaceHolder.unlockCanvasAndPost(gameCanvas);
}
}
}
}
Then, we unlock it and post. But, how can I draw everything separately?