Ha! Today I tested my game as an iPhone app instead of a universal app to force my iPad to run it in its iPhone mode (I don’t have an iPhone around). It was funny because even though I had prepared somewhat for the difference in screen resolution, some of my code wasn’t really adaptable to different screen sizes…
The actual game did scale based on screen size but all the code that positions text on the screen and the menu elements was displaying horribly on the iPhone screen.
So I decided to just change how the whole game displayed everything.
Instead of adapting the position and size of everything I wanted to display (which is what I had done for the actual game screen) I set an arbitrary pair of values for the screen size as constants (1024 and 768 but I guess the only important value is their ratio). Then, before drawing anything on the screen, I performed a scaling operation so that the vertical coordinates would be transformed from the device vertical size (0 to 480 on the iPhone) to a range of 0 to 1024. This way everything would fit on the screen no matter what it size is.
In order to keep the aspect ratio the same on all devices, I also had to center the screen horizontally depending on the difference of screen ratio, and that means I have to watch certain problems with objects that look fine on the iPad but might be drawn offscreen on an iPhone. But that’s not a big deal and much better than having all objects warped horizontally…
It’s funny how when you start something new you can’t really imagine the sort of problems you’re going to be facing, but it’s nice to manage to solve these small problems even if sometimes it means re-inventing the wheel (I know I did nothing new here… but it was fun coming up with a solution). That’s one of the things I love about coding!!
By the way… progress with my first game is good. I’ll be posting more screenshots and a video soon.