[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-16 Thread john
Your package is package com.baltz.scorched; Does that mean you're working on a scorched earth type game? It would be really crazy if you were, because I just started work on the same game, and I'm using the LunarLander game as a template as well. It's also my first game - maybe we can help each

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-16 Thread Sarnoth
You definitely need to do your game loop on a different thread. If your game loop is running in the main UI thread then while it is running the screen can't update and you can't get input events. The UI thread is what does these things. On Apr 15, 10:25 pm, Warren warrenba...@gmail.com wrote:

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-16 Thread Warren
Sarnoth, that's great to know. I'll undo the changes I made (that I thought would simply for testing it appears to have made the situation worse) then test to see if the game loop is indeed running in its own thread. On Apr 16, 12:28 pm, Sarnoth jesse.st...@gmail.com wrote: You definitely

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-16 Thread Warren
Does that mean you're working on a scorched earth type game? Maybe. :) On Apr 16, 8:53 am, john jbatk...@gmail.com wrote: Your package is package com.baltz.scorched; Does that mean you're working on a scorched earth type game? It would be really crazy if you were, because I just

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-15 Thread ellipsoidmob...@googlemail.com
The problem is your line Thread.currentThread().sleep(1000);//sleep for 1000 ms I believe with SurfaceView you have to draw your whole view on every screen refresh. You just need to loop as fast as possible and the system will throttle the speed in the calls to lockCanvas(). By sleeping for 1

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-15 Thread Warren
Thanks for the comment ellipsoidmobile. If I remove the sleep, I still don't see anything until the very end. I don't need that sleep in there for the application. I only put it in so that, hopefully, I could see what was happening a little better. Also, I thought that the SurfaceView allowed

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-15 Thread Warren
I may have found my problem. The SurfaceView class implements a function called draw(Canvas). I unwittingly created my own function draw() with the same signature, overriding the original. I'm guessing that the SurfaceView probably calls draw() during unlockCanvasAndPost(). But instead of

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-15 Thread Sarnoth
I can't really say without seeing more of the code, but based on your description of the problem I wonder if your thread is in fact a separate thread or if the run method is simply being executed in the main UI thread. Something worth checking. You can log Thread.currentThread().getName() from

[android-developers] Re: Black Screen problem with graphics update using unlockCanvasAndPost()

2009-04-15 Thread Warren
Sarnoth, I appreciate you taking the time to comment. Does that matter - if the thread isn't different? Just in case there were problems with the thread, I rewrote the program not to use a second thread and just execute the drawing loop in the view. In the code sample, I also changed draw()