Hi!
First I want to say thanks to everyone for your comments and likes! You are amazing!
I chose to work on the concept #2. This is simpler than the concept #1, but it requires the use the features of the engine that I have never used before.
So today
I read the documentation.
I do some tests to be sure that things work as I expect. Almost done.
I draw a simple graphics, only for the prototype.
I develop the core architecture, still on paper. Almost done.
If everything will be ok, Then tomorrow I will have a working prototype.
- A few words about the concept.
It is hard to describe the concept and not be identified. I will try.
The object does its way through some abstract space, on its way there are obstacle-objects.
Is it sounds familiar? Well, at least the rest of this concept is original.
Actually the object moves only along x, and these obstacles move along the y.
But it should look like the object is moving, and the obstacles are static.
And I have a question
Is it possible to draw a line, add it as a child object to the Node, and then move it?
Of course I have other questions, but I think that I will try to find the answer myself.
- A few words about different screens.
Before drawing graphics I had to decide how I would support different screens.
cocos2d-x has a really elegant solution for this. But it may seem difficult, especially the first time.
So I thought that it might be useful if I share my thoughts on this with this particular project.
I need the portrait orientation. I need the height of my layout to be fully displayed. I’m fine if the width will be cut, but I want to know how much it may be cut. And I do not want black borders.
As I understand it, the engine supports Immersive mode
by default if the device has an android version 4.4
or greater.
Looking at the android dashboards I decided to set minSdkVersion = 19
and do not worry about Status bar
and Navigation bar
.
In this case, the extreme cases for the aspect ratio are 16/9
and 4/3
. Like 2560/1440
and 2560/1920
.
Right?
So I have
static cocos2d::Size designResolutionSize = cocos2d::Size(2560, 1440);
static cocos2d::Size resourceResolutionSize2560 = cocos2d::Size(2560, 1920);
static cocos2d::Size resourceResolutionSize1280 = cocos2d::Size(1280, 960);
static cocos2d::Size resourceResolutionSize640 = cocos2d::Size(640, 480);
and
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::FIXED_HEIGHT);
auto frameSize = glview->getFrameSize();
if (frameSize.height <= resourceResolutionSize640.height)
{
director->setContentScaleFactor(resourceResolutionSize640.height/designResolutionSize.height);
}
else if (frameSize.height <= resourceResolutionSize1280.height)
{
director->setContentScaleFactor(resourceResolutionSize1280.height/designResolutionSize.height);
}
else
{
director->setContentScaleFactor(resourceResolutionSize2560.height/designResolutionSize.height);
}
There are only 2 “But”
1 . What if the Immersive mode is not supported? I’m not sure that this is possible, but I know that many vendors modify the firmware. In this case, if the screen has a 4/3
aspect ratio and has Status bar
and Navigation bar
, then we will have black borders.
Possible solutions
Use wider background images.
or
Use Director::getInstance()->setClearColor(const Color4F &clearColor)
The borders will not disappear. But in some cases, users will not notice the borders.
2 . I know at least 2 exceptions when aspect ratio > 16/9
.
854/480
(low end phones) and 2880/1440
(LG G6, Samsung Galaxy S8)
To support these devices, you need to remember that the UI and important objects must fit inside the area 2/1.
This is true only if
I need the portrait orientation. I need the height of my layout to be fully displayed. I’m fine if the width will be cut, but I want to know how much it may be cut. And I do not want black borders.
And if you use multi-screens support as I do.
Criticism is welcome.
updated
variables renamed to make it more clear