Getting dpi
There are a lot of dpi (dots per inch) variations for each device. You can prepare several kinds of images by resolution. You might want to change an image by the dpi running on the device. In this recipe, if you would like to get the dpi that your game is running on, you need to use the Cocos2d-x function.
How to do it...
You can get dpi of the device game is executing on, by using the Device::getDPI
method as follows:
int dpi = Device::getDPI(); CCLOG("dpi = %d", dpi);
How it works...
In fact, we checked the dpi of some devices. To use the dpi information, you can further adjust the multiscreen resolution.
Device |
Dpi |
---|---|
iPhone 6 Plus |
489 |
iPhone 6 |
326 |
iPhone 5s |
326 |
iPhone 4s |
326 |
iPad Air |
264 |
iPad 2 |
132 |
Nexus 5 |
480 |