I am experimenting with design resolutions with a android phone and windows PC. I am swapping back and forth and trying out various things to try better understand it. This seems to be good advice from that thread we all know about.
I have an issue though and cant figure out what.
bool TestScene::init(){
if (!Scene::init()) return false;
m_VisableSize = cocos2d::Director::getInstance()->getVisibleSize();
CCLOG("SCREEN VISIBLE WIDTH : %f SCREEN VISIBLE HEIGHT : %f\n", m_VisableSize.width , m_VisableSize.height); // PC:480x320 Android:420x270
m_WindowSize = cocos2d::Director::getInstance()->getWinSize();
CCLOG("SCREEN WINDOW WIDTH : %f SCREEN WINDOW HEIGHT : %f\n", m_WindowSize.width, m_WindowSize.height); // PC:480x320 Android:420x320
m_Origin = cocos2d::Director::getInstance()->getVisibleOrigin();
m_Scene = cocos2d::Director::getInstance()->getRunningScene();
m_GaddBox = new GaddBox();
m_Base = m_GaddBox->createLayer("Base");
m_Base->setContentSize(m_VisableSize);
m_Base->setAnchorPoint(cocos2d::Vec2(0,0));
m_Base->setPosition(cocos2d::Vec2(0,0));
CCLOG("BASE BOUNDING BOX X:%f Y:%f\n", m_Base->getBoundingBox().size.width, m_Base->getBoundingBox().size.height); // 480 x 320
this->addChild(m_Base, 0);
DesignResolutionTesting();
return true;
}
This next function im using to play around with design resolution experiments. The cubes are 50pixels
void TestScene::DesignResolutionTesting() {
float scale = 2.0;
float padding = 5.0;
cocos2d::Sprite* cube1 = cocos2d::Sprite::create("Hud/UI/red50.png");
cocos2d::Sprite* cube2 = cocos2d::Sprite::create("Hud/UI/red50.png");
cocos2d::Sprite* cube3 = cocos2d::Sprite::create("Hud/UI/red50.png");
cocos2d::Sprite* cube4 = cocos2d::Sprite::create("Hud/UI/red50.png");
cocos2d::Sprite* cube5 = cocos2d::Sprite::create("Hud/UI/red50.png");
cube1->setAnchorPoint(cocos2d::Vec2(0.5,0.5));
cube1->setPosition(cocos2d::Vec2(m_VisableSize.width / 2, m_VisableSize.height / 2));
//UniversalScalling::UniversalImageProcessing(cube1, scale, scale, false);
m_Base->addChild(cube1, 1);
cube2->setAnchorPoint(cocos2d::Vec2(0, 0.5));
cube2->setPosition(cocos2d::Vec2(padding, m_VisableSize.height / 2));
//UniversalScalling::UniversalImageProcessing(cube2, scale, scale, false);
m_Base->addChild(cube2, 1);
cube3->setAnchorPoint(cocos2d::Vec2(0.5, 1));
cube3->setPosition(cocos2d::Vec2(m_VisableSize.width / 2, m_VisableSize.height - padding));
//UniversalScalling::UniversalImageProcessing(cube3, scale, scale, false);
m_Base->addChild(cube3, 1);
cube4->setAnchorPoint(cocos2d::Vec2(1, 0.5));
cube4->setPosition(cocos2d::Vec2(m_VisableSize.width - padding, m_VisableSize.height / 2));
//UniversalScalling::UniversalImageProcessing(cube4, scale, scale, false);
m_Base->addChild(cube4, 1);
cube5->setAnchorPoint(cocos2d::Vec2(0.5, 0));
cube5->setPosition(cocos2d::Vec2(m_VisableSize.width / 2, padding));
//UniversalScalling::UniversalImageProcessing(cube5, scale, scale, false);
m_Base->addChild(cube5, 1);
auto drawnode1 = cocos2d::DrawNode::create();
drawnode1->drawLine(cocos2d::Vec2(padding, padding), cocos2d::Vec2(m_VisableSize.width - padding, padding), cocos2d::Color4F(1.0, 0.0, 0.0, 1.0));
m_Base->addChild(drawnode1);
auto drawnode2 = cocos2d::DrawNode::create();
drawnode2->drawLine(cocos2d::Vec2(padding, padding), cocos2d::Vec2(padding, m_VisableSize.height - padding), cocos2d::Color4F(1.0, 0.0, 0.0, 1.0));
m_Base->addChild(drawnode2);
auto drawnode3 = cocos2d::DrawNode::create();
drawnode3->drawLine(cocos2d::Vec2(padding, m_VisableSize.height - padding), cocos2d::Vec2(m_VisableSize.width - padding, m_VisableSize.height - padding), cocos2d::Color4F(1.0, 0.0, 0.0, 1.0));
m_Base->addChild(drawnode3);
auto drawnode4 = cocos2d::DrawNode::create();
drawnode4->drawLine(cocos2d::Vec2(m_VisableSize.width - padding, m_VisableSize.height - padding), cocos2d::Vec2(m_VisableSize.width - padding, padding), cocos2d::Color4F(1.0, 0.0, 0.0, 1.0));
m_Base->addChild(drawnode4);
int dots = 10;
for (int x = 10; x <= m_VisableSize.width - 10; x += 10) {
auto point = cocos2d::DrawNode::create();
point->drawPoint(cocos2d::Vec2(x, m_VisableSize.height / 2), 5.0, cocos2d::Color4F(1.0, 0.0, 0.0, 1.0));
m_Base->addChild(point);
dots++;
}
CCLOG("DOTS : %d", dots);
}
Display on Windows
Display on android - PROBLEM
Android above has a gap on top - Anyone know why ?
This is reason correct ?