Skip to content

Commit

Permalink
issue cocos2d#1555: Fixed coordinate conversion errors.
Browse files Browse the repository at this point in the history
It needs to be based on 'Design Resolution Size' rather than 'Frame Size'
Please refer to the implementations of CCDirector::convertToGL and CCDirector::convertToUI.
  • Loading branch information
James Chen committed Nov 16, 2012
1 parent fc85063 commit c4496d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cocos2dx/CCDirector.cpp
Expand Up @@ -455,7 +455,7 @@ CCPoint CCDirector::convertToGL(const CCPoint& uiPoint)
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
kmScalar zClip = transform.mat[14]/transform.mat[15];

CCSize glSize = m_pobOpenGLView->getFrameSize();
CCSize glSize = m_pobOpenGLView->getDesignResolutionSize();
kmVec3 clipCoord = {2.0*uiPoint.x/glSize.width - 1.0, 1.0 - 2.0*uiPoint.y/glSize.height, zClip};

kmVec3 glCoord;
Expand All @@ -474,7 +474,7 @@ CCPoint CCDirector::convertToUI(const CCPoint& glPoint)
kmVec3 glCoord = {glPoint.x, glPoint.y, 0.0};
kmVec3TransformCoord(&clipCoord, &glCoord, &transform);

CCSize glSize = m_pobOpenGLView->getFrameSize();
CCSize glSize = m_pobOpenGLView->getDesignResolutionSize();
return ccp(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5));
}

Expand Down

0 comments on commit c4496d7

Please sign in to comment.