Hi all,
i have a beginners question about setting the ContentScaleFactor.
I have a default Layout in FullHD (1080x1920), so i set
glview->setDesignResolutionSize(1080,
1920, ResolutionPolicy::NO_BORDER);
then I check the actual resolution of the device and apply it to the scaleFactor
Size frameSize = glview->getFrameSize();
float scaleFactor;
//iphone 6 Plus
if(frameSize.height == 1920)
{
scaleFactor = 1;
}
//iphone 6
else if(frameSize.height == 1334)
{
scaleFactor = 1334/designResolutionSize.height;
}
//iphone 5
if(frameSize.height == 1136)
{
scaleFactor = 1136/designResolutionSize.height;
}
//iphone 4
else if(frameSize.height ==960)
{
scaleFactor = 960/designResolutionSize.height;
}
and set the ContentScaleFactor according to this
director->setContentScaleFactor(scaleFactor);
So for my iPhone5 i got a contentScaleFactor of 0.591667, which is correct I guess.
When I now add a BackgroundSprite with an original size of 1080x1920 i expected that the contentScaleFactor gets automatically applied to it like 10800.591667 and 19200.591667, so the result should be something like 640x1134 for the Sprite.
Sprite * sprite = Sprite::create("bg.jpg");
sprite->setAnchorPoint(Vec2(0, 0));// Anchor Point
sprite->setPosition(Vec2(0,0));
this->addChild(sprite);
But instead it seems to add the half on top of the original size. So the sprite is way too big.
printf("contentWidth: %f\n", sprite->getContentSize().width); //result: 1825.352173
printf("contentHeight: %f\n", sprite->getContentSize().height); //result: 3245.070557
I know there is something I may missunderstood, could anybody help?
Greets,
D.