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 / [BUG] GetSpriteHeight() is returning the sprite width

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Feb 2016 00:47 Edited at: 22nd Feb 2016 05:15
When you use SetDisplayAspect( -1 ) the GetSpriteHeight() returns the sprite width
see attached

Sign up for NaGaCreMo!

Attachments

Login to view attachments
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Feb 2016 15:11
By default the virtual resolution is 100x100 which means square things fill the screen. Since your image is 1024x768 it fills the 1024x768 screen, therefore it's internal size needs to be square. This is confusing so I prefer to set a virtual resolution with SetVirtualResolution(1024,768) which makes more sense.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Feb 2016 15:58
I always promote not using percentage. It can get really confusing at times. Better to learn how to use virtual resolution.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 23rd Feb 2016 23:37 Edited at: 23rd Feb 2016 23:38
The percentage system shall rule all!!!!

I prefer this system, but I can see how it can confuse people easily. Just remember that 100% is not equal to 100 units. So an image that is sized to 100 , 100 in percentage system will fill the screen, but in virtual resolution, it'll be a square image that is 100 units x 100 units. And another thing to keep in mind is whenever you are calculating the y unit of an image or sprite or etc, make sure you multiply by the screen aspect ratio or it cause inaccurate results.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Feb 2016 04:33 Edited at: 24th Feb 2016 04:37
ok no worries

Sign up for NaGaCreMo!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Feb 2016 08:46
Quote: "it can confuse people easily"


Quote: "remember that 100% is not equal to 100 units."


Quote: "an image that is sized to 100 , 100 in percentage system will fill the screen"


Quote: "make sure you multiply by the screen aspect ratio or it cause inaccurate results."


This is why I use virtual resolution!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 24th Feb 2016 09:12
I honestly still find it easier to use the percentage system even after all that. To each his own I guess.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Feb 2016 09:16
I use the percentage system all the time. If I want to scale an image, I always (for example) set the scale to X = scale, Y = -1, to ensure that the height maintains the same aspect ratio to the width. (Or If it's by height I want to set it to, then it's X = -1, Y = height.)
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Feb 2016 11:19 Edited at: 24th Feb 2016 11:21
Quote: "set the scale to X = scale, Y = -1, ... Or If it's by height I want to set it to, then it's X = -1, Y = height"

That, right there is where it all comes crashing down!

I was using the percentage system for CryptoGlyphs and doing that very thing, assuming (wrongly) that everything would appear the same for all screen sizes and all aspect ratios - it doesn't!

When you mix and match x-1 and y-1 you will not get consistent results. I found out the hard way! I had been coding in a percentage based system and viewing it on a 1920x1080 screen and assumed it would look the same on all screens - percentage based right? That's what you expect.

But when the AppGameKit Player became available for Apple, I viewed my game on an iPad mini and the display was all over the place! I spent a couple of months changing the position and scale of everything to switch over to a virtual resolution and I still haven't tracked down everything. I wished I had used virtual from the start and will always do so in future.

Try it yourself. Make two rectangular sprites. One vertical and one horizontal and scale them to draw a border. Scale the top and bottom by Y-1 and the left and right by X-1. Then see what happens with different resolutions. You'll soon switch to virtual resolution too!
AGK V2 user - Tier 1 (mostly)
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 24th Feb 2016 11:27
You can scale your percentage settings by the aspect ratio so that the object appears the same on everything. Though I found you don't always want to do this because sometimes it better to make more use of the extra space.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Feb 2016 22:30
i would have thought that getspriteheight/width would return values relative to the 100/100 percentage set so if the image was 1024/768, it returns 100/100. if the image was 512/384 it returns 50/50.
i cannot see these return values being of any use at all. can anyone see any use for them?
luckily the getimageheight/width work so i can scale my images to fit any device

Sign up for NaGaCreMo!
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 25th Feb 2016 02:04
Quote: "Try it yourself. Make two rectangular sprites. One vertical and one horizontal and scale them to draw a border. Scale the top and bottom by Y-1 and the left and right by X-1. Then see what happens with different resolutions. You'll soon switch to virtual resolution too!"

You must be missing something because that is the whole reason for the percentage system, so it shows up the exact same on all devices. I've never had any issues like that before, that's with testing my apps on pc and three different mobile/tablet devices with various sizes. I've never had any issues and they always show up the same...weird
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Feb 2016 08:32
We need a new badge, especially for JLMoondog - Conqueror of the Percentage System. It needs to be platinum and very shiny
The mathematics behind it seem to elude most people.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Feb 2016 09:18
I need it too, as my apps are equally the same across multiple devices.

I love the percentage system!
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 26th Feb 2016 09:44
We could also have a badge for virtual resolution and then people can show what side they belong to
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Feb 2016 11:00 Edited at: 26th Feb 2016 11:00
What side are you on??? lol

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 09:29:06
Your offset time is: 2024-11-25 09:29:06