cocos2d中的屏幕坐标系和OPenGL坐标系转换

转自http://group.cnblogs.com/topic/57609.html


cocos2d坐标系(OPenGL坐标系):以左下角为原点,x向右,y向上

屏幕坐标系(android,ios,win32系统的坐标系):以左上角为原点,X轴向右为正,y轴向下为正

在cocos2dx的test例子中:

void TestController::cctouchesBegan(CCSet *ptouches,CCEvent *pEvent)
{
CCSetIterator it = ptouches->begin();
CCTouch* touch = (CCTouch*)(*it);


CCPoint m_tBeginPos = touch->locationInView();
m_tBeginPos = CCDirector::sharedDirector()->convertToGL( m_tBeginPos );
}

CCTouch中触摸点的位置是使用屏幕坐标系的,

convertToGL把屏幕坐标系的点的位置转成OPengl坐标系的位置

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...