Skip to content

Commit 4deca65

Browse files
committed
Fixed screen mode transitions.
Former-commit-id: fe866ef
1 parent 98955aa commit 4deca65

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cocos2d/CCTransition.m

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ - (id)initWithDuration:(NSTimeInterval)duration
112112
_outgoingOverIncoming = NO;
113113

114114
// find out where the outgoing scene will end (if it is a transition with movement)
115-
CGSize size = [CCDirector sharedDirector].designSize;
115+
CGSize size = [CCDirector sharedDirector].viewportRect.size;
116116
switch (direction) {
117117
case CCTransitionDirectionDown: _outgoingDestination = CGPointMake(0, -size.height); break;
118118
case CCTransitionDirectionLeft: _outgoingDestination = CGPointMake(-size.width, 0); break;
@@ -188,21 +188,25 @@ - (void)startTransition:(CCScene *)scene
188188

189189
// create render textures
190190
// get viewport size
191-
CGSize size = [CCDirector sharedDirector].designSize;
191+
CGRect rect = [CCDirector sharedDirector].viewportRect;
192+
193+
// Make sure we aren't rounding down.
194+
rect.size.width = ceil(rect.size.width);
195+
rect.size.height = ceil(rect.size.height);
192196

193197
// create texture for outgoing scene
194-
_outgoingTexture = [CCRenderTexture renderTextureWithWidth:size.width / _outgoingDownScale
195-
height:size.height / _outgoingDownScale
198+
_outgoingTexture = [CCRenderTexture renderTextureWithWidth:rect.size.width / _outgoingDownScale
199+
height:rect.size.height / _outgoingDownScale
196200
pixelFormat:_transitionPixelFormat];
197-
_outgoingTexture.position = CGPointMake(size.width * 0.5f, size.height * 0.5f);
201+
_outgoingTexture.position = CGPointMake(rect.size.width * 0.5f + rect.origin.x, rect.size.height * 0.5f + rect.origin.y);
198202
_outgoingTexture.scale = _outgoingDownScale;
199203
[self addChild:_outgoingTexture z:_outgoingOverIncoming];
200204

201205
// create texture for incoming scene
202-
_incomingTexture = [CCRenderTexture renderTextureWithWidth:size.width / _incomingDownScale
203-
height:size.height / _incomingDownScale
206+
_incomingTexture = [CCRenderTexture renderTextureWithWidth:rect.size.width / _incomingDownScale
207+
height:rect.size.height / _incomingDownScale
204208
pixelFormat:_transitionPixelFormat];
205-
_incomingTexture.position = CGPointMake(size.width * 0.5f, size.height * 0.5f);
209+
_incomingTexture.position = CGPointMake(rect.size.width * 0.5f + rect.origin.x, rect.size.height * 0.5f + rect.origin.y);
206210
_incomingTexture.scale = _incomingDownScale;
207211
[self addChild:_incomingTexture];
208212

0 commit comments

Comments
 (0)