What is the usage of getVisibleOrigin()

What is the usage of getVisibleOrigin()
0.0 0

#1

I don’t understand the point of getVisibleOrigin() if the x and y value are zero, just use 0 as a raw value, basically why would some use getVisisbleOrigin() in practicality?


#2

Well, I’m just a new guy to this game engine, but I will explain in my best ability.
First, Imagine you have a background for design resolution. Then, the design resolution is transformed to your screen solution by specified POLICY.

Of course, there are cases that your background will not be fully displayed by the screen.And the part of background displayed by the screen is Visible Area.

That’s why you don’t want to set your widgets’ position by the design resolution, because if you do, these widgets may be not displayed fully in the screen. That’s why you need to getVisibleOrigin() to return the point on the bottom left of your screen, but this doesn’t mean this origin point is (0,0), it could be (xx,yy).
No matter what the number is, the only thing you need now is the Visible Origin of the screen so we use that point and make sure that those widgets always display in the screen.

For example:
If I have design resolution of 1080 x 1920 FHD screen aspect ratio 16:9
Then It will transformed to 1050 X 1920 (just a randome number) mobile screen by FixHeight Policy
Now you can see on the screen , we lost 30 px of the background. So if you put these widgets on the side of design resolution, these widgets may not be fully displayed.
But If you have Visible Origin, you can start from there and make sure widgets are in the screen.


#3

But in my case I have FIXED_HEIGHT policy and still getVisibleOrigin() returns Size(0, 0).
I set my designResolutionSize() yet the visibleOrigin is still 0,0? Do you have an idea of what could be
causing this? thanx :slight_smile:


#4

Can you give a specific number of your design resolution and the screen resolution?
I need more details on this.


#5

Edit: wiki has been removed.
http://www.cocos2d-x.org/wiki/Multi_resolution_support