Rendering few Sprites in different Aspect Ratio in Scene

Hello

I have completed a game in Cocos2dx. The game is designed for iPad (design size is 1024*768).
Now i want to port this to iPhone (including iPhone 5). The game as it is runs fine in iPhone (full screen) (due to Multiple resolution support in cocos2dx) , But there are very few sprites in some scenes which looks bad due to stretching (Like Buttons which are in circle shape). I want to render these few sprites in correct aspect ratio. How can we achieve this ?

Regards
Krithik

Try using different stretching methods. They say the best method is to use kResolutionNoBorder but the best one I’ve found is kResolutionFixedWidth for landscape apps and kResolutionFixedHeight for portrait apps.

Use CCScale9Sprite or CCControlButton for sprites like buttons

Thank you for the reply .

Currently i am using kResolutionExactFit and it looks fine expect for few sprites (which are circle) as i told before . If i use kResolutionFixedHeight big black space will appear in right side .
The game contains more than 100 levels so i don’t want to rework on each level . I am thinking of solution like changing the design resolution for only one sprite (or few sprites) in the scene while rendering .

If anyone is trying for the solution you can try like this .

void LMUtility::setDeviceScaleFactor(CCSize inScreenSize,CCSize inDesignSize,ResolutionPolicy inResolutionPolicy)
{
    float xScaleFactor = 0.0f;
    float yScaleFactor = 0.0f;

    float finalXScaleFactor = 0.0f;
    float finalYScaleFactor = 0.0f;


    xScaleFactor = (float)inScreenSize.width / inDesignSize.width;
    yScaleFactor = (float)inScreenSize.height / inDesignSize.height;

    if (inResolutionPolicy == kResolutionNoBorder)
    {
        xScaleFactor = yScaleFactor = MAX(xScaleFactor, yScaleFactor);
    }

    if (inResolutionPolicy == kResolutionShowAll)
    {
        xScaleFactor = yScaleFactor = MIN(xScaleFactor, yScaleFactor);
    }

    if ( inResolutionPolicy == kResolutionFixedHeight) {
        xScaleFactor = yScaleFactor;
    }

    if ( inResolutionPolicy == kResolutionFixedWidth) {
        yScaleFactor = xScaleFactor;
    }


    if(xScaleFactor>1.0)
    {
        finalXScaleFactor = 1+(1.0f-xScaleFactor);
    }
    else
    {
        finalXScaleFactor = 1.0f+(1.0f-xScaleFactor);
    }

    if(yScaleFactor>1.0)
    {
        finalYScaleFactor = 1+(1.0f-yScaleFactor);
    }
    else
    {
        finalYScaleFactor = 1.0f+(1.0f-yScaleFactor);
    }

    LMDataManager::sharedManager()->xScaleFactor = finalXScaleFactor;
    LMDataManager::sharedManager()->yScaleFactor = finalYScaleFactor;
}

void LMUtility::setCorrectAspectRatioForSprite(CCNode *inNode)
{
    inNode->setScaleX(LMDataManager::sharedManager()->xScaleFactor);
    inNode->setScaleY(LMDataManager::sharedManager()->yScaleFactor);
}

void LMUtility::setCorrectAspectRatioForSprite(CCNode *inNode)
{
    inNode->setScaleX(LMDataManager::sharedManager()->xScaleFactor);
    inNode->setScaleY(LMDataManager::sharedManager()->yScaleFactor);
}

Then you can apply for any CCNode like

LMUtility::setCorrectAspectRatioForSprite(aNode);