2013-02-16 19:36:21 +08:00
|
|
|
#include "CCDevice.h"
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-02-17 17:13:06 +08:00
|
|
|
int CCDevice::getDPI()
|
2013-02-16 19:36:21 +08:00
|
|
|
{
|
2013-02-17 17:13:06 +08:00
|
|
|
static int dpi = -1;
|
|
|
|
|
|
|
|
if (dpi == -1)
|
|
|
|
{
|
|
|
|
float scale = 1.0f;
|
|
|
|
|
|
|
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
|
|
|
|
scale = [[UIScreen mainScreen] scale];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
dpi = 132 * scale;
|
|
|
|
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
|
|
|
|
dpi = 163 * scale;
|
|
|
|
} else {
|
|
|
|
dpi = 160 * scale;
|
|
|
|
}
|
2013-02-16 19:36:21 +08:00
|
|
|
}
|
|
|
|
return dpi;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|