cocos2d-x节点(b2EdgeShape.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。
- ///cocos2d-x-3.0alpha0/external/Box2D/Collision/Shapes
- // 一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。
- #ifndef B2_EDGE_SHAPE_H
- #define B2_EDGE_SHAPE_H
- #include <Box2D/Collision/Shapes/b2Shape.h>
- // 一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。
- //连接信息是用来确保正确的联系法线
- class b2EdgeShape : public b2Shape
- {
- public:
- b2EdgeShape(); //构造函数
- // 设置独立的边缘
- // * 参数说明: v1 : 第一个顶点
- // v2 : 第二个顶点
- void Set(const b2Vec2& v1, const b2Vec2& v2);
- // :用soa块分配器克隆一个具体的形状
- // * 参数说明: allocator :soa分配器对象指针
- // * 返 回 值: 形状指针
- b2Shape* Clone(b2BlockAllocator* allocator) const;
- // 获取形状的孩子元素的数量
- /// @see b2Shape::GetChildCount
- int32 GetChildCount() const;
- // 在这个形状中测试这个点的密封性,只适合用于凸的形状
- // * 参数说明: xf : 形状的变换
- // p : world坐标中的一个点
- // * 返 回 值: true : 密封
- // false:敞开
- /// @see b2Shape::TestPoint
- bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
- // :投射一束光到一个孩子形状中
- // * 参数说明: output :输出光线投射的结果
- // input :输入光线投射
- // transform :变换应用到此形状中
- // childeIndex :孩子形状索引
- // * 返 回 值: true : 成功
- // false:失败
- bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
- const b2Transform& transform, int32 childIndex) const;
- // * 功能描述:给出一个变换,计算一个孩子形状的轴对齐包围盒(aabb)
- // * 参数说明: aabb : 孩子形状的aabb指针
- // xf : 一个变换的引用
- // childIndex : 孩子的索引值
- /// @see b2Shape::ComputeAABB
- void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
- // 用它的大小和密度计算形状的质量
- // * 参数说明: massData : 计算形状的质量
- // density : 密度
- /// @see b2Shape::ComputeMass
- void ComputeMass(b2MassData* massData, float32 density) const;
- // 边缘形状的顶点
- b2Vec2 m_vertex1, m_vertex2;
- // 可选的相邻的顶点,它们用于平滑碰撞
- b2Vec2 m_vertex0, m_vertex3;
- bool m_hasVertex0, m_hasVertex3; //是否含有相邻顶点
- };
- //构造函数,用于初始化
- inline b2EdgeShape::b2EdgeShape()
- {
- m_type = e_edge;
- m_radius = b2_polygonRadius;
- m_vertex0.x = 0.0f;
- m_vertex0.y = 0.0f;
- m_vertex3.x = 0.0f;
- m_vertex3.y = 0.0f;
- m_hasVertex0 = false;
- m_hasVertex3 = false;
- }
- #endif