So iv been trying to figure out how to draw shapes and images to a surfaceview. iv been using multiple tutorials. but now im lost. i have a Thread that has my game loop and from what i understand im am to have all variable updates in this loop
public void run() {
Canvas c;
while (running) {
c = null;
try {
c = surfaceHolder.lockCanvas(null);
synchronized (surfaceHolder) {
//Insert methods to modify positions of items in onDraw()
}
} finally {
if (c != null) {
surfaceHolder.unlockCanvasAndPost(c);
}
}
}
}
I have a surfaceView that has the onDraw(Canvas canvas) method. Say i want to add oval to my screen how do i do that from my while loop in my thread
i currently have these variables in my thread class
private SurfaceHolder surfaceHolder;
private gameMain gamePanel; //my surfaceview class
private boolean running;
and do i need to have this in my surfaceview class ?
setWillNotDraw(false);
if im doing it completely wrong people point it out. i do not wish to use openGL or any libraries