Hi All,
I’m developing a game with cocos2dx (cocos2d-2.1beta3-x-2.1.1) where the game scene has the size of a tiled map that I use as background. This game scene is bigger than the device screen and during the game I keep the player character in the center of the screen moving the layer’s camera. Here is the code:
void GameLayer::zoomPoint(cocos2d::CCPoint position) {
static cocos2d::CCSize screenSize = cocos2d::CCDirector::sharedDirector()->getWinSize();
static float maxOriginDistanceX = ((m_sailingFieldMap->getContentSize().width - screenSize.width) * 0.5);
static float maxOriginDistanceY = (m_sailingFieldMap->getContentSize().height - screenSize.height);
// get the layer's CCCamera values
float centerX, centerY, centerZ;
float eyeX, eyeY, eyeZ;
getCamera()->getCenterXYZ(¢erX, ¢erY, ¢erZ);
getCamera()->getEyeXYZ(&eyeX, &eyeY, &eyeZ);
centerX = eyeX = position.x;
centerX = eyeX = cocos2d::clampf(centerX, - maxOriginDistanceX, maxOriginDistanceX);
centerY = eyeY = (position.y - screenSize.height * 0.5f);
centerY = eyeY = cocos2d::clampf(centerY, 0.0f, maxOriginDistanceY);
getCamera()->setCenterXYZ(centerX, centerY, centerZ);
getCamera()->setEyeXYZ(eyeX, eyeY, eyeZ);
}
Now I have a problem, the visualization of the scene depends on the screen resolution. With iPad1 and iPad2 (1024x768) I have a good visualization, with iPad3 and iPad4 (2048x1536) the visualization is too small (in this case the tiled map is not enough width to fill the screen).
How can I resolve this problem avoding to prepare the same images with different resolutions?
Is there a way to solve the problem using the camera?
Consider that all my graphics stuff is a vectorial format then I can change the resolution of the png (I woluld like to avoid mantaing the same image in different png and resolution).
Thanks for the help.
Giannandrea