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 / GetSpriteHeight VS GetImageHeight

Author
Message
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Apr 2012 21:19
Hi,
The GetSpriteHeight function returns a different value than the GetImageHeight
Please note that:
1. The image has transparent border
2. The image has dimensions equal to the power of 2
3. The image is single (no subimages, atlas etc)

Did I miss something?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Apr 2012 22:05
i think that if you set a shape to your sprite, then the sprite height will be that of the actual opaque pixels of your sprite and NOT include the size of the transparency
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Apr 2012 22:08
The image height is the size of the original image in pixels, sprite size can be set by pixels or percentage of screen size and the aspect ratio of a sprite can differ from the original image.

george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Apr 2012 23:25 Edited at: 15th Apr 2012 23:26
The only graphics initialization I've done is:

The original image has the following dimensions: 160x32 pixels
The 'GetImageHeight' function returns 32 pixels
The 'GetSpriteHeight' function returns 21.333332 pixels
I run the application in Windows mode and my desktop resolution is 1920 x 1080 pixels
Is there any relationship or what?
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th Apr 2012 03:00
As baxslash says, you are comparing the image height to the sprite height, which can be two different values. If you want your sprite to match your image dimensions, I recommend setting the virtual resolution at the start. Then as long as you are using the image to create the sprite or are sizing it to match, it should match.
If you are not setting the virtual resolution from default, it is set to 100x100. So if you are resizing the sprites down to match that, the image will never be the same size.

However, looking at your code snippet you already setting a resolution :p

Are you setting it to match in your setup file? If not that may be the culprit.

Lastly, are you running in a window, a maximized window, or full screen? I'm not too sure how AppGameKit handles fullscreen but if it is scaling to your resolution, as it seems to when maximized (obviously), it may also change your image and sprite values accordingly.

Oh as baxslash mentioned also, the screen ration will change things. But I assume you have not changed that in the code beyond your set resolution command. But if you are using a widescreen monitor, which is likely, 640x480 is not the correct display ratio for fullscreen or maximised. So you will need to rethink your resolution settings a little to work for your monitor.

So if there is any relationship it must be your display ratio.

Login to post a reply

Server time is: 2024-05-09 00:06:57
Your offset time is: 2024-05-09 00:06:57