Skip to content

Commit 8e8a648

Browse files
committed
Tablet configuartion is supported for Android
1 parent 677a8cd commit 8e8a648

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

cocos2d/CCConfiguration.m

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,34 @@ -(NSInteger) runningDevice
146146
NSInteger ret=-1;
147147

148148
#if __CC_PLATFORM_ANDROID
149-
if([CCDirector sharedDirector].contentScaleFactor > 1.0)
150-
{
151-
ret = CCDeviceiPhoneRetinaDisplay;
152-
}
153-
else
154-
{
155-
ret = CCDeviceiPhone;
149+
150+
151+
AndroidDisplayMetrics *metrics = [[AndroidDisplayMetrics alloc] init];
152+
[[CCActivity currentActivity].windowManager.defaultDisplay getMetrics:metrics];
153+
double yInches= metrics.heightPixels/metrics.ydpi;
154+
double xInches= metrics.widthPixels/metrics.xdpi;
155+
double diagonalInches = sqrt(xInches*xInches + yInches*yInches);
156+
if (diagonalInches<=6){
157+
158+
159+
if([CCDirector sharedDirector].contentScaleFactor > 1.0)
160+
{
161+
ret = CCDeviceiPhoneRetinaDisplay;
162+
}
163+
else
164+
{
165+
ret = CCDeviceiPhone;
166+
}
167+
} else {
168+
if([CCDirector sharedDirector].contentScaleFactor > 1.0)
169+
{
170+
ret = CCDeviceiPadRetinaDisplay;
171+
}
172+
else
173+
{
174+
ret = CCDeviceiPad;
175+
}
176+
156177
}
157178
#elif __CC_PLATFORM_IOS
158179

0 commit comments

Comments
 (0)