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 / Sprite size

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Sep 2013 16:54
I think that I will ask a stupid question but I am stuck!
The sprite size is only 64x64 pixels but when I run the program (T1) the sprite is very large (please see attached image)



Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Sep 2013 17:02
Try using "setSpriteSize". As you are using "setDisplayAspect" this means you are using the percentage system so size your sprites as a percentage of the screen. If you use "-1" for one of the values it will preserve the aspect ratio for you.

For example to get a sprite the size of the image on screen when using the percentage system:


"Everything should be made as simple as possible, but not simpler."
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Sep 2013 17:06 Edited at: 13th Sep 2013 17:07
I tested your code (with another image of comparable size) in both v1076 and v10819 and got the same results.

Apparently, if you don't provide a size for a sprite it defaults to the image size. And, since you are using a percentage system, 50 becomes 50 percent instead of 50 pixels.

So, a word to the wise, if using the percentage system, you need to explicitly size your sprites.

EDIT: Everyone is ninjaing me today!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Sep 2013 21:51
Thank you very much both.

Quote: "...50 becomes 50 percent instead of 50 pixels."


A bit more light to my darkness!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Sep 2013 17:43
Yeah, if you find the percentage system awkward, Just use setvirtualresolution(x,y). That way you can use actual pixel sizes rather than percentages. Far easier to work with in the main.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 15th Sep 2013 18:22
Quote: "Far easier to work with in the main."

I agree. And it also means that the width/height ratios of your images don't get messed with.

My current WIP was initially targeted for the iPhone high res (960x640). And I have discovered that it looks just great on everything of that resolution or higher. Including my hubby's iPad 3.

AGK does a great job of handling the scaling up of stuff for display on higher resolutions (without messing with your game logic, which still thinks it is only 960x640).

And there are tricks for dealing with the black bar issues for devices with total width/height ratio that is different from your target one.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 17th Sep 2013 22:41
So, virtual resolution is better than the percentage system?
Personally I don't find the percentage system awkward.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Sep 2013 00:33
Virtual vs percentage comes down to personal preference and comfort zones and such.

Being mildly OC about wanting things being where I tell them to be, I prefer the virtual system.

Others swear by the percentage system.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Sep 2013 09:15
For my game I use a resolution of 200x120 (this is derived from 800x480 which was common on Android devices, like Galaxy S2). Then I started using the SetScissor( 0, 0, 0, 0 ) command to fill the entire screen. Now I know that anything 240x150 will cover any screen ratio and anything inside 200x120 will always be visible. Knowing the exact coordinates makes it so much easier to work with images. Not sure I could have made Rush to Adventure without it. I don't know how I would go about positioning tiles etc using percentage.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Sep 2013 12:10
Quote: "Virtual vs percentage comes down to personal preference and comfort zones and such."

Also some games suit one system over the other. I use both depending on the game although these days I tend to use the percentage mentality in the virtual resolution system. What I mean is I tend to set the size of objects based on a percentage of the size of the screen but using the virtual resolution to simplify trigonometry.

If you are using "sin()", "cos()", "tan()" in the percentage system for example you need to take the aspect ratio into account. Same for other trig commands such as "atanfull()".

"Everything should be made as simple as possible, but not simpler."

Login to post a reply

Server time is: 2024-11-24 20:01:16
Your offset time is: 2024-11-24 20:01:16