Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition to new Multi-resolution adaption scheme #1289

Closed

Conversation

moadib
Copy link
Contributor

@moadib moadib commented Sep 6, 2012

I've added ability to use setContentScaleFactor() in pair with setDesignResolutionSize() on all platforms.

Example from real life, we have "iphone" and "iphonehd" resource folders and want make our android game with this resources.

We won't make additional assets which adopted for 720x480 resolution. But just scale all with CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll); isn't as good as it can be. It is still use "iphone" resources

What i suggest?

if (pDirector->getWinSize().height > 320)
{
    CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
    pDirector->setContentScaleFactor(2.0f);  // attention! must be called before setDesignResolutionSize
}
else
    CCFileUtils::sharedFileUtils()->setResourceDirectory("normal");

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll);

How it works?
It is also scaled to 720x480, but uses resources for retina. I think that everyone understand that downscaled texture looks better than upscaled :)
And it is work without any changes in game code.

Of course you still can use all as designed by developers.

lamerman pushed a commit to Game-Insight/cocos2d-x that referenced this pull request Sep 6, 2012
fixed cocos2d#1289: CCControlButton update. Added zoomOnTouchDown property and setPreferredSize.
float zeye = m_obWinSizeInPixels.height / 1.1566f;
if (m_pobOpenGLView->isRetinaEnabled())
zeye /= CC_CONTENT_SCALE_FACTOR();
return zeye;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about add a line space before "return zeye"?

…d not in setContentScaleFactor()

Replaced tabs with spaces to match cocos2dx codestyle
@moadib
Copy link
Contributor Author

moadib commented Sep 7, 2012

Look at last changes, i I have considered your comments and added little changes for ios CCEGLView
Now we have run example code on New Ipad too.

Anyway, if you won't pick this pullrequest i insist that you move assignment of m_bIsRetinaEnabled to enableRetina(). It will be more clear from point of logic :)

@minggo
Copy link
Contributor

minggo commented Sep 7, 2012

As you can see, in samples/HelloCpp, we also use hd resources for all android devices.

@moadib
Copy link
Contributor Author

moadib commented Sep 7, 2012

Yes, but you have different "design resolutions" for iphone without retina and other. Also you don't use "normal" resources for android devices with 480x320 resolution.

The idea is to use the same design resolution as possible. As option, of course.

@walzer
Copy link
Contributor

walzer commented Sep 12, 2012

moadib, I love this idea :)

@moadib
Copy link
Contributor Author

moadib commented Sep 12, 2012

In our repos we have modified cocos2d so that remove word Retina from library and all classes. Only terms that we use in our logic are "design resolution" and "contet scale factor" :)

@minggo
Copy link
Contributor

minggo commented Sep 14, 2012

Could you share your repos?
Is it https://github.com/moadib/cocos2d-x?

@moadib
Copy link
Contributor Author

moadib commented Sep 14, 2012

No, it is in our local repo :) Ok, i think that @BorMor can share it later.

@minggo
Copy link
Contributor

minggo commented Sep 16, 2012

Thank you.

@minggo
Copy link
Contributor

minggo commented Sep 24, 2012

@moadib
This pull request do similar work as you. And it does more work.
#1366

Could you please have a look?
And i think your pull request is better about how to use content scale factor.

@moadib
Copy link
Contributor Author

moadib commented Sep 24, 2012

Take a look at pull-request of @BorMor (we work together) http://github.com/cocos2d/cocos2d-x/pull/1372

@moadib moadib closed this Sep 24, 2012
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 28, 2014
fixed cocos2d#1289: CCControlButton update. Added zoomOnTouchDown property and setPreferredSize.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 29, 2014
fixed cocos2d#1289: CCControlButton update. Added zoomOnTouchDown property and setPreferredSize.
dumganhar pushed a commit that referenced this pull request May 4, 2014
fixed #1289: CCControlButton update. Added zoomOnTouchDown property and setPreferredSize.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants