1.屏幕坐标系
屏幕坐标系是以左上角作为坐标原点,x正方向向右,y正方向向下,如图 的一个坐标系。
2.OpenGL坐标系
以左下角作为坐标原点,x正方向向右,y正方向向上,如图的一个坐标系。
3.世界坐标系
又叫绝对坐标系,其值是固定的,默认原点在左下角。
4.本地坐标系
物体本身的坐标系
5.锚点
由x,y值在0~1之间的点,按比例设置。
eg:
(0,1) (1,1) (0,0) (1,0)
分别为:↖左上顶点,↗右上顶点,↙左下顶点,↘右下顶点。
setAnchorPoint(); getAnchorPoint(); setIsRelativeAnchorPoint(); getIsRelativeAnchorPoint(); 设置锚点,获得锚点
设置是否相对锚点,true:相对锚点,false:不相对锚点
6.坐标系转换
CCDirector::convertToGL(CCPoint); CCDirector::convertToUI(CCPoint); CCPoint convertToNodeSpace(const CCPoint& worldPoint); //转换为节点的本地坐标 CCPoint convertToWorldSpace(const CCPoint& nodePoint); //转换为世界坐标系 CCPoint convertToNodeSpaceAR(const CCPoint& worldPoint); CCPoint convertToWorldSpaceAR(const CCPoint& nodePoint);
使用较多的坐标是相对于子节点的父节点图层的坐标,本地坐标系。
7.逻辑数值与真实数值
//逻辑值 getContentSize(); //获取原始尺寸大小 scale后不改变这个值 getPosition(); //真实值 getContentSizeInPixels();//获取改变后的尺寸大小 getPositionInPixels();//改变后的位置 //缩放因子 CCDirector::setContentScaleFactor(1.0f); CCDirector::enableRetinaDisplay(false);//contentScaleFactor=1.0 真实值 = 逻辑值*1 CCDirector::enableRetinaDisplay(true);//contentScaleFactor=2.0 真实值 = 逻辑值*2
ps:坐标实验如下图
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|