![]() | onDraw not drawing the bitmap right away |
|
03 Jul 2009, 03:23
Win Myo Htet (31 posts) |
I am writing a tic tac toe game. I am having issue onDraw drawing required Bitmap one step late. When the “select” method with “invalidate()” at the end is called after touching the screen, onDraw is called but the bitmap supposed to be drawn at the block is not drawn. The onDraw executes the canvas.drawBitmap (I see the Log.d msg right after it and get into canvas.drawBitmap with debug mode too) but I am not seeing the bitmap. However the bitmap will be draw, if I touch another block (whose bitmap also doesn’t get drawn until I touch another block). The bitmap won’t get drawn if I keep touching the same block. Thx |
|
01 Jul 2009, 17:57
Win Myo Htet (31 posts) |
hmm….interesting finding, if I select the bottom right corner block, it will draw bitmap right away and it will draw bitmap right away if select blocks from right to left and then bottom up (reverse of right to left top down). However if I select block out of that reverse sequence, it exhibits the same problem, not drawing the bitmap right away. |
|
01 Jul 2009, 22:34
Ed Burnette (1316 posts) |
Unfortunately your code got mangled by the forum software; see http://www.pragprog.com/resources/markup-in-forums. If you want, you can mail it to my gmail.com address (ed.burnette@g...). But my first guess as to what’s happening is that “curRect” isn’t set to what you think it is by the time you get into onDraw. onDraw() is called by Android at some random time in the future after your select() function returns. In it, you want to draw the entire view—the whole board. You probably didn’t mean to reference curRect in the Game.UN_MARK case of onDraw(). |
|
04 Jul 2009, 06:21
Win Myo Htet (31 posts) |
Thanks Ed for the help via email. You help me solved the issue. |
|
04 Jul 2009, 18:08
Ed Burnette (1316 posts) |
Glad to help. |
| You must be logged in to comment |

