mirror of https://github.com/axmolengine/axmol.git
[iOS] fix: enableRetina() and setDesignResolutionSize() can not be used simultaneously. FROM kunlun.com, THANKS
This commit is contained in:
parent
1313398335
commit
6eabead4e3
|
@ -87,6 +87,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
BOOL preserveBackbuffer_;
|
||||
|
||||
CGSize size_;
|
||||
CGFloat designContentScaleFactor_;
|
||||
BOOL discardFramebufferSupported_;
|
||||
|
||||
//fsaa addition
|
||||
|
@ -142,6 +143,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
|
||||
@property(nonatomic,readwrite) BOOL multiSampling;
|
||||
|
||||
/** call from AppController.mm */
|
||||
-(void) setDesignContentScaleFactor:(CGFloat)scale;
|
||||
-(CGFloat) getDesignContentScaleFactor;
|
||||
|
||||
/** EAGLView uses double-buffer. This method swaps the buffers */
|
||||
-(void) swapBuffers;
|
||||
|
|
|
@ -134,6 +134,7 @@ static EAGLView *view = 0;
|
|||
{
|
||||
if((self = [super initWithFrame:frame]))
|
||||
{
|
||||
designContentScaleFactor_ = 1.0;
|
||||
isUseUITextField = YES;
|
||||
pixelformat_ = format;
|
||||
depthFormat_ = depth;
|
||||
|
@ -162,6 +163,7 @@ static EAGLView *view = 0;
|
|||
|
||||
CAEAGLLayer* eaglLayer = (CAEAGLLayer*)[self layer];
|
||||
|
||||
designContentScaleFactor_ = 1.0;
|
||||
pixelformat_ = kEAGLColorFormatRGB565;
|
||||
depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES;
|
||||
multiSampling_= NO;
|
||||
|
@ -200,15 +202,27 @@ static EAGLView *view = 0;
|
|||
-(int) getWidth
|
||||
{
|
||||
CGSize bound = [self bounds].size;
|
||||
return bound.width;
|
||||
return bound.width * designContentScaleFactor_;
|
||||
}
|
||||
|
||||
-(int) getHeight
|
||||
{
|
||||
CGSize bound = [self bounds].size;
|
||||
return bound.height;
|
||||
return bound.height * designContentScaleFactor_;
|
||||
}
|
||||
|
||||
-(void) setDesignContentScaleFactor:(CGFloat)scale
|
||||
{
|
||||
if ([self respondsToSelector:@selector(setContentScaleFactor:)]) {
|
||||
[self setContentScaleFactor:scale]; // if val == 2.0, enable retina display
|
||||
designContentScaleFactor_ = scale;
|
||||
}
|
||||
}
|
||||
|
||||
-(CGFloat) getDesignContentScaleFactor
|
||||
{
|
||||
return designContentScaleFactor_;
|
||||
}
|
||||
|
||||
-(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup
|
||||
{
|
||||
|
@ -401,8 +415,8 @@ static EAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x;
|
||||
ys[i] = [touch locationInView: [touch view]].y;
|
||||
xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_;
|
||||
ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_;
|
||||
++i;
|
||||
}
|
||||
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys);
|
||||
|
@ -421,8 +435,8 @@ static EAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x;
|
||||
ys[i] = [touch locationInView: [touch view]].y;
|
||||
xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_;
|
||||
ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_;
|
||||
++i;
|
||||
}
|
||||
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys);
|
||||
|
@ -442,8 +456,8 @@ static EAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x;
|
||||
ys[i] = [touch locationInView: [touch view]].y;
|
||||
xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_;
|
||||
ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_;
|
||||
++i;
|
||||
}
|
||||
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys);
|
||||
|
@ -463,8 +477,8 @@ static EAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x;
|
||||
ys[i] = [touch locationInView: [touch view]].y;
|
||||
xs[i] = [touch locationInView: [touch view]].x * designContentScaleFactor_;
|
||||
ys[i] = [touch locationInView: [touch view]].y * designContentScaleFactor_;
|
||||
++i;
|
||||
}
|
||||
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys);
|
||||
|
@ -786,6 +800,15 @@ static EAGLView *view = 0;
|
|||
break;
|
||||
}
|
||||
|
||||
begin.origin.x *= designContentScaleFactor_;
|
||||
begin.origin.y *= designContentScaleFactor_;
|
||||
begin.size.width *= designContentScaleFactor_;
|
||||
begin.size.height *= designContentScaleFactor_;
|
||||
end.origin.x *= designContentScaleFactor_;
|
||||
end.origin.y *= designContentScaleFactor_;
|
||||
end.size.width *= designContentScaleFactor_;
|
||||
end.size.height *= designContentScaleFactor_;
|
||||
|
||||
cocos2d::CCIMEKeyboardNotificationInfo notiInfo;
|
||||
notiInfo.begin = cocos2d::CCRect(begin.origin.x,
|
||||
begin.origin.y,
|
||||
|
@ -859,6 +882,7 @@ static EAGLView *view = 0;
|
|||
// NSLog(@"[animation] dis = %f\n", dis);
|
||||
|
||||
if (dis < 0.0f) dis = 0.0f;
|
||||
dis /= designContentScaleFactor_;
|
||||
|
||||
if (!cocos2d::CCEGLView::sharedOpenGLView()->isRetinaEnabled())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue