首页 > 其他 > 详细

cocos2dx 坐标系

时间:2015-08-31 17:30:02      阅读:250      评论:0      收藏:0      [点我收藏+]

cocos2dx中有几种坐标系:

  1. GL坐标系以左下角为原点,向上为Y,向左为X

  2. 屏幕坐标系以左上角为原点,向下为Y,向右为X


    屏幕坐标系使用的是不同的坐标系统,原点在屏幕左上角,x轴向右,y轴向下。iOS的屏幕触摸事件CCTouch传入的位置信息使用的是该坐标系。因此在Cocos2D-x中对触摸事件做出响应前,需要首先把触摸点转化到OpenGL坐标系。

①从触摸点获取到在屏幕坐标系中的坐标
// returns the current touch location in screen coordinatesCCPoint CCTouch::() const { 
    return m_point; 
}

②从触摸点获取到在OpenGL坐标系中的坐标// returns the current touch location in OpenGL coordinatesCCPoint CCTouch::getLocation() const{ 
    return CCDirector::sharedDirector()->convertToGL(m_point); 
}

cocos2dx 坐标系

原文:http://cxdbk.blog.51cto.com/8808491/1690165

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!