• cocos2d-x 坐标系解惑


    1、CCTouch* touch->getLocation() ---- 返回当前触摸点在openGL坐标系中的位置

      openGL坐标系,原点在左下角,x向右为正,y向上为正。

    2、CCTouch* touch->getLocationInView() ---- 返回当前触摸点在屏幕坐标系中的位置

      视图坐标系,原点在左上角,x向右为正,y向下为正。

      经测试以上两个结果值,x一样,y值不一样。

    3、CCDirector->sharedDirector()->convertToGL(CCPoint* point)------把poit从一个UIKit 框架坐标系转换到OpenGL坐标系。把(多点)触摸坐标转换到当前布局(layout)(垂直或水平)时非常有用。

      1的结果= 2 + 3

    4、CCDirector->sharedDirector()->convertToUI(CC:point* point)----把point从OpenGL坐标系转换为UIKit 框架坐标系。 非常适合节点坐标(Node Points)转换为窗口坐标(Window Points)时调用。比如glScissor.

      2 = 1 + 4

    5、CCLayer* layer->convertToNodeSpace(CCPoint* worldpoint)---把worldpoint 转换为节点(本地)坐标系坐标(node space coordinates)。

      结果跟worldpoint一样,如果worldpoint 是GL坐标,结果就跟GL坐标一样,若是视图坐标,结果跟View坐标一样。

    6、CCLayer* layer->convertToWorldSpace(CCPoint* nodepoint)---把nodepoint转换为世界坐标系坐标(world space coordinates)。

       结果跟nodepoint一样,如果nodepoint 是GL坐标,结果就跟GL坐标一样,若是视图坐标,结果跟View坐标一样。

    7、CCLayer* layer->convertToNodeSpaceAR(CCPoint* worldPoint) --- 把worldPoint转换为节点坐标系坐标,返回的节点坐标是锚点坐标(treating the returned/received node point as anchor relative.)。

      AR的结果跟别的都不同,具体意义还不清楚。

    8、CCLayer* layer->convertToWorldSpaceAR(CCPoint* nodePoint)--- 把nodepoint转换为世界坐标系坐标(world space coordinates)。返回的坐标是锚点坐标(treating the returned/received node point as anchor relative.)。

       AR的结果跟别的都不同,具体意义还不清楚。worldAR 跟 nodeAR也不同。

    9、CCLayer* layer->convertTouchToNodeSpace(CCTouch* touch)---- 用touch替代point的便捷方法。

      结果跟1,3,5的结果一样

    10、CCLayer* layer->convertTouchToNodeSpaceAR(CCTouch* touch)---- 用touch替代point的便捷方法。

      结果跟7一样

  • 相关阅读:
    前端代码异常日志收集与监控
    基于window.onerror事件 建立前端错误日志
    MySQL数据类型和常用字段属性总结
    MySQL中char(36)被认为是GUID导致的BUG及解决方案
    dl,dt,dd,ul,li,ol区别
    泛型
    EF里Guid类型数据的自增长、时间戳和复杂类型的用法
    EF里的默认映射以及如何使用Data Annotations和Fluent API配置数据库的映射
    EF里的继承映射关系TPH、TPT和TPC的讲解以及一些具体的例子
    SQL JOIN
  • 原文地址:https://www.cnblogs.com/patientAndPersist/p/3546256.html
Copyright © 2020-2023  润新知