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 / GetSpriteYByOffset doesn't return same value

Author
Message
Tomakin
8
Years of Service
User Offline
Joined: 4th Apr 2016
Location:
Posted: 4th Apr 2016 16:10
Hi,

I encountered a problem in my program (here is a example where the problem is isolated)



To understand the problem, "map.jpg" has a resolution of 6144 x 6144 pixels (I know it's big)

when the line "Set Virtual resolution.." is enabled, the values are :
wid# = 6144
hei# = 6144
xbo# = 3072
ybo# = 3072

which are the expected values for me

But, when the line "Set Virtual resolution.." is disabled, (and i'm working with percentage mode in my program), the values are :
wid# = 6144
hei# = 6144
xbo# = 3072
ybo# = 4096

Did I miss something ?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Apr 2016 19:15
GetSpriteX() returns the top left corner.
GetSpriteXByOffset() returns the middle of the sprite. (Or wherever it's been offset to.)

Of course they'll be different.
Tomakin
8
Years of Service
User Offline
Joined: 4th Apr 2016
Location:
Posted: 4th Apr 2016 20:00
Yes I know that, but in both cases it is GetSpriteXByOffset(), but in the second case (where SetVirtualResolution is disabled), GetSpriteYByOffset() doesn't return the same value than the first case (also a GetSpriteYByOffset()).

There is no GetSpriteX() at all.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2016 20:13 Edited at: 4th Apr 2016 20:13
If you use the percentage system, you must also use SetDisplayAspect() to configure the screen.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Tomakin
8
Years of Service
User Offline
Joined: 4th Apr 2016
Location:
Posted: 4th Apr 2016 20:40
With SetDisplayAspect(-1) , the value ybo# becomes :

5461.333496 (instead of 3072) on a computer in 1920x1080 (16/9 aspect ratio)

and

4915.200195 (instead of 3072) on another computer in 2560x1600 (16/10 aspect ratio)

the mystery grows
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th Apr 2016 21:09
Two possible causes:

1.
What is your desktop/monitor resolution? When you use SetWindowSize( 1920, 1080, 1 ) the flag for fullscreen doesn't care about the resolution in this command. Which could result in the differences.

2.
Using percentage system could mess up the values. BatVink could be on to something. If so, I say it's another reason to go with virtual resolution instead.
Tomakin
8
Years of Service
User Offline
Joined: 4th Apr 2016
Location:
Posted: 5th Apr 2016 07:11
I have tested with different size of images and on different computers, and finally found that the GetSpriteYByOffset() command in percentage system gives a wrong value each time. GetSpriteXByOffset() works.

To obtain the right value of GetSpriteYByOffset(), I need to divide the result by the aspect ratio of the computer i'm using.

It solves my problem for now, and thank you for your advices.

Login to post a reply

Server time is: 2024-09-29 13:34:28
Your offset time is: 2024-09-29 13:34:28