Feature suggestion: check if retina display is enabled

It would be good to have some code to check if the current device has the retina display enabled. It’s an interesting feature since if we, for example, download a profile picture from facebook (or any picture from the internet), you might be interested on scaling the picture depending on if Retina is enabled or not.

Jesús

Your “profile picture” will be scaled correctly anyway as Cocos2D works in points, not pixels.

If for some reason you do want to check if enableRetina is set, call CCDirector::getContentScaleFactor()" which should be 2 if running on a retina device, or 1 for SD.

I just see the picture half size when I enable the retina display, so I need to scale it up.

thanks for the code tip :slight_smile:

In the latest release(v2.0.2), there is a member funciton ‘CCEGLView::isRetinaEnabled()’ for checking whether retina was enabled.

Hi James,

The functions CCEGLView::isRetinaEnabled() and CCEGLView::enableRetinaDisplay() seem to have disappeared in the latest version (cocos2d-2.1beta3-x-2.1.0). Could you please advise on what the equivalent functions are now? Thank you for your help.

Ben

Looks like it’s been depreciated, probably because it was iOS specific, says use ContentScaleFactor now, see here: http://www.cocos2d-x.org/issues/1486

As for enabling it I’m not sure, I’ve not looked at this version yet.

GavT GMTDev wrote:

Looks like it’s been depreciated, probably because it was iOS specific, says use ContentScaleFactor now, see here: http://www.cocos2d-x.org/issues/1486
>
As for enabling it I’m not sure, I’ve not looked at this version yet.

Good find, thank you. It makes a lot of sense to make everything use ContentScaleFactor. I’ve decided to stay with version 2.0.3 for now to avoid any potential confusions with this kind of thing. I’ve found that it’s quite difficult to make multi-resolution support work nicely with CCBReader, and retina on top was more fiddling still. Like you, I think I’ll pick this up again when I’ve got a little more time to mess around with it all…

Ben