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.

Newcomers AppGameKit Corner / Screen Width / Height best practice

Author
Message
Khadin
9
Years of Service
User Offline
Joined: 13th Feb 2015
Location: Nottingham
Posted: 25th Apr 2015 18:12
Hi all.

I normally make two Globals; sW = 1366, and sH = 768. I use AppGameKit on a monitor with that resolution.

Now i've replaced them with sW = getdevicewidth(), and sH = getDeviceHeight() but the sprites are not where i expect them to be. What is the best practice when determining Width, and Height of your game?

Let's say i wanted a sprite to sit half way across the screen. I'd use the code; setSpritePosition(SpriteID, sW /2, 0) etc.

Should i set my sW, sH - getDeviceHeight/Width() and arrange the sprites from then on in?

Thanks,

Khadin
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Apr 2015 21:46
There are quite a few different ways of doing this. I have to say "it depends" because if you are producing a desktop only app you might be thinking of making a windowed app, if you are aiming for mobile then you probably need more of a catch-all method.

For mobile I tend to decide whether the height or width of the screen is most important and size all sprites based on that height. Also you might want to consider sticking with a set "virtual" resolution.

For example I might create a landscape side scrolling app and decide the height should remain constant at 600. Then I'd calculate the width based on the display aspect IE:
SH = 600
SW = (GetDeviceWidth()*1.0) / (GetDeviceHeight()*1.0) * 600
SetVirtualResolution(SW, SH)

There are so many different "but if" possibilities you will have to feel your way for a while before it clicks.

Hope that helps a little!

Using AppGameKit V2 Tier 1
Khadin
9
Years of Service
User Offline
Joined: 13th Feb 2015
Location: Nottingham
Posted: 25th Apr 2015 23:54
Hey baxslash.

Yep it does thanks It's for mobile i'm aiming at, but i'll just do some trial and error.

Khadin

Login to post a reply

Server time is: 2024-11-23 11:28:17
Your offset time is: 2024-11-23 11:28:17