Nuances of game design in portrait and landscape modes

Hi,

Previously I was developing a game in landscape mode.
So I set designResolution and resource folders handling this way:

static Resource smallResource  =  { cocos2d::Size (480.0f, 320.0f),   "SD"  };
static Resource mediumResource =  { cocos2d::Size (1024.0f, 768.0f),  "HD"  };
static Resource largeResource  =  { cocos2d::Size (2048.0f, 1536.0f), "HDR" };

static Size designResolution = Size (1024.0f, 768.0f);

I was assuming that the origin point of the screen will be bottom-left corner (is it true?)

Now, I begin with another game that should run in portrait mode.
So I set designResolution and resource folders handling this way:

static Resource smallResource = { cocos2d::Size (320.0f, 480.0f), “SD” };
static Resource mediumResource = { cocos2d::Size (768.0f, 1024.0f), “HD” };
static Resource largeResource = { cocos2d::Size (1536.0f, 2048.0f), “HDR” };

static Size designResolution = Size (768.0f, 1024.0f);

Where will be the origin point now? Top-left corner?

Can someone please clarify this and maybe other issues about this topic.

Regards,
Mike

It should depend on which orientation mode whether portrait/landscape you have set inside AndroidManifest.xml
or corresponding file for iOS(which I don’t know)…

So, it has to be always left-bottom…
I am quite sure about this.

1 Like

The origin is always at the bottom left corner.

As @catch_up was pointing out, you might have rotated your screen to be upside down. This will rotate the canvas and also it’s origin point, as it is always fixed to the canvas.

1 Like

@catch_up @iQD Thanks guys!

So I’m doing well? (design Resolution and resource folders handling)

I tell you what confused me…

This new book about cocos2d-x: http://cdn.oreillystatic.com/oreilly/booksamplers/packt/9781783988266_Sample.pdf

In chapter 1 page 19:

Coordinate system

Coordinate systems are used to determine the position of the objects on the screen.
Cocos2d-x uses a rectangular coordinate system with the bottom-left corner of the
screen being the origin in landscape mode and top-left corner in portrait mode.
From the bottom-left corner of the screen, imagine a line going straight towards the
bottom-right corner, which would be the x axis, and a line going up from the origin
to the top-left corner, which would be the y axis. There is also a z axis that is coming
out of the screen from the origin. This is irrespective of whether you are holding the
device in the landscape or the portrait position. Refer to the following fi gure:

Yes.

It’s just wrong.
If you turn your phone by hand to portrait, than yes, it’s in the top-left corner :smile:

See here:
http://www.cocos2d-x.org/wiki/Coordinate_System
http://www.cocos2d-x.org/wiki/Device_Orientation

1 Like