Finally, after lot of reading and lot of pondering, I got started on designing a simple game so that I could test my knowledge. I zeroed on a Trivia game as it is really simple to design. One question will follow the next and at the end a score will be displayed. I used netbeans as the ide. Well the game got designed rather quickly but I ran into rough weather with image display and audio playback. After some googling of concepts, i was able to display images, add a midlet icon, play a tone at the end of game in the simulator. It was great. But then I transferred the jar to my motorola a1200 handset and immediately there were problems. The image at start won't display. The game would hang.
I kept reading about Motorola handsets, but to no avail. Finally I realized that it is the java applications manager on the a1200 which was not able to cope with the amount of work being done at runtime. So I got the images created in constructor of canvas. Still it won't work. I had made canvas runnable, but then I removed it, thinking it might be because of the 2 threads running concurrently that could cause the problem. Still no success !!!
So today I fixed the form for right answer and wrong answer and got them filled in the constructor. During run time I would just choose the right form to be displayed. And so the game finally ran its course on A1200. But the image at startup won't display. I read a lot about paint() and how setCurrent(canvas) will call the paint(), but for some foggy reason, it didn't work on A1200. And all the time it would work on the simulator.
And then I stumbled upon it. In the sample code on the internet, I saw that the anchor "Graphics.TOP" was being used in conjunction with "Graphics.LEFT". And I was not using the TOP anchor. I immediately changed it and finally I got the results that I wanted. A simple trivia game that will display an image at the start and run its course properly. Wow!!!!!!!!!!!!!!!!!!
Now on to bigger challenges. A new adventure game which will have a lot of sprites action and of course sprites collision detection.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment