Question

I am quite new to Gideros and game development as well.

I am trying to build a game, it looked fine with the Gideros player, but when I tried with an Android phone, the background was way too small. I changed its properties to autoscaling so as to fit in with the width. The background now fits in the width, but other objects seem to go to absurd locations.

Though I was using W = application:getDeviceWidth(), H = application:getDeviceHeight(), and while setting up the location, used W/2 and H/2 instead of hardcoding it. However, this object that seems to shift to rightmost bottom end(in landscape left mode) was right at its center if I do not apply fit width property. What can I do to fix it?

Was it helpful?

Solution

You should use W = application:getContentWidth() , H = application:getContentHeight() which would return logical dimensions that are used when in scaling mode.

Basically it all brings down to these points:

1) Choose the scaling mode that is proper for your game (Letterbox being most popular)

2) Choose logical dimensions for your game and create all the graphics for logical dimensions you set in the project properties (recommended 480x800 or 640x960)

3) Create backgrounds a little more bigger than logical dimensions to cover whitespaces on devices with different ratios

4) Use absolute positioning (http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects) for objects that need to stick to sides of the screen as on screen buttons for example

5) (Optionally) prepare bigger graphics in in some fixed ratio coefficient and use Automatic Image Resoltuion feature to automatically load them for bigger devices

More information available here: http://members.giderosmobile.com/knowledgebase.php?action=displayarticle&id=79

Addition: (Difference between device and logical dimensions)

Device dimensions is exactly what device has. Meaning on an iPhone 3GS it will return width as 320

But logical dimensions are exactly what you set in your project properties. No matter what resolution you have, the logical dimensions will always be the same. They basically will be scaled based on the scale mode you choose.

Here are more specifics on that topic: http://appcodingeasy.com/Gideros-Mobile/Difference-between-content-logical-and-device-dimensions-in-Gideros-Mobile

So if you are developing only for one specific resolution, you can use Device dimensions, otherwise it is suggested to use Logical dimensions with the scale mode you find suitable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top