Managing projects for running on different iPad generations

Hi All,

Will be getting a 2022 new iPad at Xmas and just thought it would be a good idea to set up a system for scaling the graphics from my old 768 by 1024 to any iPad.

I have some ideas and a little code from when I was playing with Elite Galaxies on my existing pad. I’m sure there are some of you members who have already resolved this so any hints would be appreciated.

From the outset I see two options - scale the graphics or run the old code in a window on the screen using offsets .

I try to make positions and sizes of sprites, etc relative to the WIDTH and HEIGHT constants. e.g.

sprite(asset.buttonimg, WIDTH*0.5, HEIGHT*0.9, WIDTH*0.05, HEIGHT*0.05)

If you are sticking to iPads this is OK with the fixed spect ratio of 16:9 across generations. If you want iPhone compatibility too then this goes out the window due to the changes in aspect ratio. I’ve not found a simple solution to this but don’t often do it.

Another simple workaround might be to encase the draw function in


your code


But this would probably have only limited use, and wouldn’t take into account touches

@West - thanks for the feedback, your first example is the method I have used before deriving the scaling factor from the ratio of WIDTH or HEIGHT on the device I used to develop the project in to the values of the same variables in the currently used device. I have tended to use two factors separating WIDTH and HEIGHT as I thought the aspect ratio has changed a little with each generation.

Thanks again for the feedback.

I think the ratio was pretty consistent across most iPads (Pro 11 inch and Air being different)

I worried about backwards compatibility too when I upgraded, but with the level I’m using it for (personal hobby) I found I really wasn’t going back to old code too much so would just modify the old code as and when needed

@West - both of my iPads are Pro, one 11 inch. Have not used the 11 inch (will be doing come Sunday) and anything I program in future will be using scaling. But, I have a large accumulated library of Codea code, mainly my own unfinished projects, which I am currently sorting and will hopefully be updating to get compatibility.

When finished I will probably have a few projects to post here but, at the moment, I get very little time for pad access.