Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

iOS and MacOS / Use of different assets in different resolutions? (x1, x2, x4)

Author
Message
dragonade30
10
Years of Service
User Offline
Joined: 27th Aug 2013
Location:
Posted: 27th Aug 2013 18:41
First, I want to apologize if this topic has been addressed in the past. I feel like it would have been already, but much to my surprised (or lack of understanding), I was not able to find the answer I was looking for. If you have a link to another thread with the answer I'm looking for, I would appreciate a post with it for me to read through it. Otherwise, I hope to get answers here.

Assume that I am using AppGameKit V1 to try and create a game app that can be played on many different iOS devices with different resolutions (iPhone 4/S, iPhone 5, iPad 1&2&Mini and iPad 3&4). I know that we can use the percentage system to allow auto-scaling. However, I was wondering if it was possible to have the application use a different set of assets/images depending on the resolution size.

Anyone who has programmed in XCode in Objecctive-C for the iOS platform knows what I'm referring to. When developing for iPhone 3GS, 4/S and iPad Retina devices, it was possible to have 1x, 2x and 4x scaled assets. The files would be named "someAssetName.png", "someAssetNamex2.png" and "someAssetNamex4.png". If the application detected that it was running on and iPad Retina device, it would automatically use the assets ending in "x4", and so on for the other resolutions.

So I'm wondering if this was possible with the AppGameKit V1? An alternative solution (though I heard AppGameKit V1 doesn't do this) is to work with x4 assets only and have AppGameKit V1 automatically scale the images down to x2 (without stretching).

Any helpful responses would be appreciated. Thank you in advance.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 27th Aug 2013 21:13 Edited at: 27th Aug 2013 21:14
It is totally doable. But you have to program it yourself.

It looks like you are going to ignore the iPhone, iPhone 3G and iPhone 3GS with 480x320 resolution, but that can be added later.

Let's assume:
1x = iPhone 4, iPhone 4S - 960x640
2x = iPhone 5 - 1136x640
3x = iPad 2, iPad mini - 1024x768
4x = iPad 3, iPad 4 - 2048x1536

The first step is to detect the actual resolution of the device (sample code in Tier 1, same commands for Tier 2, just add 'agk::' before and ';' after, and change the variable definition):


You figure out whether you are on an iPad or iPhone device:


Now figure out what resolution


Then you do all your image loads building the names something like "someAssetName"+addToImg+".png".

You can create functions to do the setup and then do the image load:


Now, these are very simple functions and could be added to. For instance, you could pass the directory to use for loading images and you should check to see if it exists.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
dragonade30
10
Years of Service
User Offline
Joined: 27th Aug 2013
Location:
Posted: 28th Aug 2013 15:47
Thank you very much for the complete and helpful response! Sounds like it's nothing too major to do then. I do have another related question though.

Since the iPhone 5 resolution is just the same as the iPhone 4/S resolution + 196 pixels on one side, I was wondering if there was a way to place an image that is exactly 1136 by 640 pixels centered on the screen, even on the iPhone 4/S resolution (960 × 640 pixels).

This means that, regardless of whether the app is running on the iPhone 4/S or the iPhone 5, the same asset is used. The only difference is that 98 pixels will be cut off from the left and right side of the asset when running on the iPhone 4/S (which is 100% ok by design). Is this possible with the AppGameKit V1 library?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Aug 2013 19:17
That is totally possible. Use the command SetScissor(0,0,0,0) to allow the app to be overdrawn (filling black bars) and use the iPhone 4/S resolution.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 12th Sep 2013 01:35 Edited at: 12th Sep 2013 01:36
Tomorrow (now im on ipad) i will give you 4 lines of code in obj c that do the same as lady given you in agk.
I never used 2x,4x ....
And i always release universal apps, and never used the scissors. I use the entire screen.
Is really simple.
See you tomorrow.

Long life to Steve!
Alain91
12
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 26th Sep 2013 10:16
Another great tutorial from Ancient Lady !

I had the same question, thanks for asking it

Alain
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Sep 2013 17:23
As I seem to recall, I did the code pretty much off the top of my head.

I'm glad to be of help.

Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 30th Oct 2013 15:44
Sorry i understood it was for iOS...
But now i see the basic code and say "sorry".


Long life to Steve!

Login to post a reply

Server time is: 2024-04-18 22:02:03
Your offset time is: 2024-04-18 22:02:03