本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(b2CircleShape.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
圆形不能是空心的
///cocos2d-x-3.0alpha0/external/Box2D/Collision/Shapes
//圆形不能是空心的
#ifndef B2_CIRCLE_SHAPE_H
#define B2_CIRCLE_SHAPE_H
#include <Box2D/Collision/Shapes/b2Shape.h>
/// 圆形状 ,继承自b2Shape.
class b2CircleShape : public b2Shape
{
public:
b2CircleShape(); //圆形构造函数
// 用soa块分配器克隆一个具体的形状【实现b2shape】
// * 参数说明: allocator :soa分配器对象指针
/// Implement b2Shape.
b2Shape* Clone(b2BlockAllocator* allocator) const;
//获取形状的子对象的数量
/// @see b2Shape::GetChildCount
int32 GetChildCount() const;
// 在这个形状中测试这个点的密封性,只适合用于凸的形状
// * 参数说明: xf : 形状的变换
// p : world坐标中的一个点
// * 返 回 值: true : 密封
// false:敞开
/// Implement b2Shape.
bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
// 投射一束光到一个圆形状中
// * 参数说明: output :输出光线投射的结果
// input :输入光线投射
// transform :变换应用到此形状中
// childeIndex :孩子形状索引
// * 返 回 值:?++? true : 成功
// false:失败
/// Implement b2Shape.
bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& transform, int32 childIndex) const;
// 给出一个变换,计算一个圆形状的轴对齐包围盒(aabb)
// * 参数说明: aabb : 孩子形状的aabb指针
// xf : 一个变换的引用
// childIndex : 孩子的索引值
// * 返 回 值: true : 成功
// false:失败
/// @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;
// 根据既定的方向,得到支撑顶点索引
// 圆形没有顶点,故永远返回0
// * 参数说明: d :二维列向量
/// Get the supporting vertex index in the given direction.
int32 GetSupport(const b2Vec2& d) const;
// 根据既定的方向,得到支持的顶点
// 获取支撑点索引,圆形没有顶点,故永远返回0
// * 参数说明: d :二维列向量
/// Get the supporting vertex in the given direction.
const b2Vec2& GetSupportVertex(const b2Vec2& d) const;
//获取顶点数量
/// Get the vertex count.
int32 GetVertexCount() const { return 1; }
// 通过索引获得一个顶点,用于b2Distance
// * 参数说明:(void)
// * 返 回 值: 坐标点
const b2Vec2& GetVertex(int32 index) const;
/// Position //坐标点
b2Vec2 m_p;
};
//构造函数
inline b2CircleShape::b2CircleShape()
{
m_type = e_circle;
m_radius = 0.0f;
m_p.SetZero();
}
//获取支撑点索引,圆形没有顶点,故永远返回0
inline int32 b2CircleShape::GetSupport(const b2Vec2 &d) const
{
B2_NOT_USED(d);
return 0;
}
//获取支撑点数量
inline const b2Vec2& b2CircleShape::GetSupportVertex(const b2Vec2 &d) const
{
B2_NOT_USED(d);
return m_p;
}
//通过索引获得一个顶点,用于b2Distance
inline const b2Vec2& b2CircleShape::GetVertex(int32 index) const
{
B2_NOT_USED(index);
b2Assert(index == 0);
return m_p;
}
#endif