I'm working on an RPG for Android, using the LunarLander API demo. I've already made a game using this demo (Porcupine Assassin, check it out!) so I've got a good grasp of the Canvas class and things of that nature.
My problem is, in RPGs you need a way to access inventory, stats, etc. So I've set the BACK button to start the class Inventory.java. I'm running into problems when I finish() the Inventory activity and try to return to the game (the SurfaceView).
This is the SurfaceCreated() callback:
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.start();
}
I was getting an FC caused by "IllegalThreadStateException: thread already started" so I put a try/catch in the SurfaceCreated() callback. With the try/catch, no FC happens, but I return to a black screen.
I tried taking the try/catch out and adding a check in the beginning: if(!thread.isAlive()). That way, if the thread was already started, it wouldn't do anything. Oddly enough, I got the same FC "thread already started" so thread.isAlive() must've returned false.. ??
I also have the onWindowFocusChanged() method from the API:
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
if (!hasWindowFocus) thread.pause();
else thread.setState(STATE_RUNNING);
}
I'm pretty keen on the gaming side of this, I've got most of the groundwork for my RPG laid out. But it's all this Android/Java stuff that goes over my head. Can anyone point me in the right direction?