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.

AppGameKit Classic Chat / Percentage vs virtual resolution

Author
Message
Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 12th Oct 2012 23:02
I have always used the percentage system. However I am now looking at moving to the virtual resolution. My concern is that if I force a resolution will my game scale to the correct size on different phones and tablets or will it play on the size that I set the resolution to? Can I set the resolution to getDeviceWidth and getDeviceHeight to overcome that problem?
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 12th Oct 2012 23:25
If you set the virtual resolution to, for example, 320x480, then X of 320 and Y of 480 will always be the right-bottom of the screen. No matter what is the original resolution of the phone.

So, answering your question, yes it scales.

Follow me on twitter! @MotionStruct
Motion Struct blog
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 12th Oct 2012 23:54
If you pick a virtual resolution that doesn't have the same ratio as a device, AppGameKit puts unobtrusive black bars above/below (letter boxing) the app.

I program for 960x640 (iPhone hi-res, pre iOS 6.0) and the app still looks good on my iPad.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Oct 2012 23:55
Another way to look at it, is that using percentages is like having a virtual resolution of 100x and 100y.

And it seems that, if you "oversize" your background, and use scissors of 0,0,0,0 - you can have your backgound instead of the black border you would get on devices with different display aspects. I think that's right, I haven't tried it though.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Oct 2012 00:09
At first I found the percentage system the most logical along with an aspect ratio. More recently I've found using an 'ideal' virtual resolution IE. 1024x768 is far more practical when using trigonometry such as Pythagoras / Sin / Cos / Tan.

It's just easier for more complicated games involving physics and complex angle calculations.


this.mess = abs(sin(times#))
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 13th Oct 2012 16:55 Edited at: 13th Oct 2012 17:04
Quote: " Can I set the resolution to getDeviceWidth and getDeviceHeight to overcome that problem?"

Yes you can, that's pretty much how I do things.

I've always used to Virtual Resolution system, but with a few tweaks to use the full screen area on any device.

Firstly establishing the native resolution and orientation using devMin# and devMax# to represent the shortest and longest edges of the display, devAspect# represents the ratio of these ( >= 1.0 ) and devIsLandscape to indicate landscape orientation.

These values are then translated to match the working resolution - set by providing a new "min" value.

At the start of the game and when the display orientation changes, devIsLandscape is redetermined and the screen dimensions are calculated.

All code within the game uses these variables to calculate the positions of objects.

Where orientation will affect position, a conditional branch is used by checking devIsLandscape

The above sets the position of an object to the right in landscape and below in portrait.

All sizes and positions are based on virtMin#, so for example for a tile map, with 8 tiles visible, I use something such as

From here changing the working resolution of the game is simply a matter of changing the value set in virtMin# and everything adjusts.
Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 16th Oct 2012 20:11
Thanks guys
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 16th Oct 2012 20:28
Quote: "And it seems that, if you "oversize" your background, and use scissors of 0,0,0,0 - you can have your backgound instead of the black border you would get on devices with different display aspects. I think that's right, I haven't tried it though."

It works but only on sprites.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 16th Oct 2012 20:48
The percentage system is too abstract, since 50% one way is not equal to 50% the other way, unless the aspect ratio is 1:1

Virtual resolution is the only way for an old programmer, if you ask me.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 16th Oct 2012 23:48
Well I guess I'll stand for equality and say that the percentage system works fine for me

But I think I'll try virtual for my next project just to have tried it so I can make a proper decision.

My hovercraft is full of eels
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th Oct 2012 00:33
Quote: "It works but only on sprites."


If you can give me an example of when it doesn't work I'll fix it

I would like SetScissor(0,0,0,0) to become the easiest way to remove black borders without worrying about device resolutions.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 17th Oct 2012 01:02
What does SetScissor(0,0,0,0) exactly do?

How can it remove black borders? Will the image get stretched ignoring the original aspect ratio?

I'm very curious about this option!
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 17th Oct 2012 01:13
SetScissor normally clips all drawing to the specified rectangle, SetScissor(0,0,0,0) turns off all clipping so the full display is used.

For example, say the device resolution is 1024x768 and the app uses SetVirtualResolution(924,768) for whatever reason. By Default AppGameKit will place a black border of width 50 pixels either side of your virtual resolution and center it on the device. AppGameKit uses SetScissor(0,0,924,768) so all drawing is clipped to your resolution and anything placed at say SetSpritePosition(-50,0) would be invisible under the black border on the left.

Using SetScissor(0,0,0,0) in this case would prevent the clipping of sprites so positioning a sprite at -50,0 would display the sprite at the left edge of the screen, even though it is outside your virtual resolution. If the same program we run on a device with a 924x768 resolution there would normally be no black borders, so SetScissor(0,0,0,0) has no effect and positioning a sprite at -50,0 would be off the left edge of the screen and not be visible.

Another way of thinking about it is everything within your virtual resolution (in this case 924x768) is guaranteed to be visible. Using SetScissor(0,0,0,0) means that on *some* devices you will be able to see more of your world, i.e. those sprites placed in negative territory.
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 18th Oct 2012 12:36
Will you be able to get touch screen hits, if you click on sprites that are outside the virtual resolution?

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Oct 2012 17:19
Yes, they will report negative values (or values greater than 924 or 768 in the above example) for the X or Y location.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Oct 2012 21:53
Quote: "If you can give me an example of when it doesn't work I'll fix it

I would like SetScissor(0,0,0,0) to become the easiest way to remove black borders without worrying about device resolutions. "

I simply noticed that the clear color (cls) when changed to blue etc.

gave me black borders

But you use sprites for backgrounds and the rest

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 19th Oct 2012 01:03
Good point. There is another command SetBorderColor that can change the border color to match, but from 108 onwards if you have not explicitly set a border color the border will now copy the clear color.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 19th Oct 2012 01:24
Quote: "Good point. There is another command SetBorderColor that can change the border color to match, but from 108 onwards if you have not explicitly set a border color the border will now copy the clear color."

Sounds alot better
And paul

I now have an brand new ultrabook thanks to agk

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Davee
12
Years of Service
User Offline
Joined: 6th Sep 2011
Location: North West of England
Posted: 16th Dec 2012 15:10 Edited at: 16th Dec 2012 15:11
Marl

Quote: "I've always used to Virtual Resolution system, but with a few tweaks to use the full screen area on any device.
"

Any chance you could get this code into a small demo so i can see how it all fits together in the context of a app. I am having trouble working out which variables need to be global and stuff.
Davee
12
Years of Service
User Offline
Joined: 6th Sep 2011
Location: North West of England
Posted: 17th Dec 2012 02:47
I managed to get this working more or less how Marl says it should. The part that didn't work was the change in orientation. You end up with the game taking up the right 2 thirds of the display and the left third being negative x coordinates.

This does leave me wondering how we know if the orientation has changed so it can be handled, what notifies your app when orientation changes.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 17th Dec 2012 18:18
I would imagine getorientation() would do that. I tend to lock the app in landscape mode myself, and set my game up for that res using the setscissor command as stated above by a few people. The only problem is arranging the screen to look okay on all systems, as at least in 1076, the border is difficult to work around at the moment.
For instance say you have some text at 0,0 and want that to be at the top left corner. Using setscissormode(0,0,0,0) will add a border dependant on the device and res you set. The text will appear to move into the screen, unless you set it to a negative value. Using a negative value will fix it, but on a device that doesn't have a border, you will lose the text. So at the moment, although a nice easy way to get games going, it isn't ideal. The new version has more commands for this I believe, but is still beta, so I am nervous of using in any released app, and haven't investigated it yet.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 17th Dec 2012 18:24 Edited at: 17th Dec 2012 18:27
In the earlier example I used
Quote: "
devIsLandscape = ( getDeviceWidth() > getDeviceHeight() )
"

to determine if the orientation is landscape.

If width > height (ie landscape) then this is 1, otherwise it is zero.

It does of course rely on the device width and height being reported based on orientation - which it seems to do on Android

This is something I started doing instead of getorientation() since some devices report orientation differently.

Login to post a reply

Server time is: 2024-05-07 00:56:26
Your offset time is: 2024-05-07 00:56:26