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 / Background stretches horizontally but not vertically...

Author
Message
ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 28th Nov 2012 16:28
How come my background stretches width wise but not height wise?

My background is a portrait pic which is 640x960.

I then set the virtual resolution to 640x960 with the orientation set to portriat. But when I run my app on my device( which has a resolution of 720x1280), it fills the screen width wise but has black borders on the top and bottom.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Nov 2012 16:56
That is because the ratio of height to width is not the same.

640/960 = 0.666666
720/1280 = 0.5625

Since you specified the width and height, AppGameKit will maintain that ratio in all displays.

Cheers,
Ancient Lady
AGK Community Tester
ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 28th Nov 2012 17:25 Edited at: 28th Nov 2012 18:05
So what your saying is that instead specifying a width and height, I should find out that ratio of the device and use a function using the ratio?

Edit:
So the SetDisplayAspect function is my answer then?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Nov 2012 18:11
SetDisplayAspect is used when you are using a percentage based system. Then you would need to change your code to work with the percentage system.

If you are more concerned about filling the screen and not worried about the stretching/shrinking effects on your graphics, then you would switch to the percentage system.

If you are more concerned about keeping your graphics looking as you created it and and want to be able to control things with specific locations (like SetSpritePosition(1,150.0,250.0)), then you stick with using virtual resolution and ignore the bars.

I am sticking with a fixed size for my app and not worrying about the black bars above and below.

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 28th Nov 2012 18:55
If you use setscissor(0,0,0,0) then you should be able to use a virtual resolution. It will still have black borders dependant on the device resolution/aspect, but you could oversize your screen so it fills the gap. I have used this method with 2 apps now, and although not ideal works ok on all devices I tried so far.
You can also get the devicewidth and height and set your virtual resolution to that. Then when placing you would want to use a percentage to position things. That way it should work on all devices also. the only problem you get that way is scale issues. It worked well for Moon Snaker though. the orientation can also confuse things. Also on phones/tablets with a high res it can slow things down a fair bit if your game is busy.
I must admit I still am always unsure which way to go whenever I start a project regarding the resolution. I have never used the percentage system of AppGameKit though as I find it horrible to use. You would imagine that it would be the best way to work if you knew which ratios you need for all devices.
Marl posted a little code snippet on a thread I posted not long back that may help you with a virtual resolution, and placing stuff down by percentage rather than pixel values.

ThrOtherJoJo
12
Years of Service
User Offline
Joined: 24th Mar 2012
Location: California
Posted: 28th Nov 2012 19:54
Ok. I believe I got it now. I am going with ratios.

Thanks!
gbison
13
Years of Service
User Offline
Joined: 15th Dec 2010
Location: USA
Posted: 28th Nov 2012 21:25
Quote: "I am sticking with a fixed size for my app and not worrying about the black bars above and below.
"


Agreed

"The greatest trick the devil ever pulled, was to convince the world he didn't exist."

Login to post a reply

Server time is: 2024-11-24 04:56:05
Your offset time is: 2024-11-24 04:56:05