cocos2d-x节点(CCPhysicsJoint.h)API

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-x节点(CCPhysicsJoint.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

各种无力物理联合,别针、限制、联动、弹簧....等联合

///cocos2d-x-3.0alpha0/cocos2dx/physics
//各种无力物理联合,别针、限制、联动、弹簧....等联合


#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS

#ifndef __CCPHYSICS_JOINT_H__
#define __CCPHYSICS_JOINT_H__

#include "cocoa/CCObject.h"
#include "cocoa/CCGeometry.h"

NS_CC_BEGIN

class PhysicsBody;
class PhysicsJointInfo;
class PhysicsBodyInfo;

/*
 * @brief 一个PhysicsJoint对象连接两个物理机构.
 */
class PhysicsJoint : public Object
{
protected:
    PhysicsJoint();
    virtual ~PhysicsJoint() = 0;

public:
    PhysicsBody* getBodyA() { return _bodyA; }
    PhysicsBody* getBodyB() { return _bodyB; }
    
protected:
    bool init(PhysicsBody* a, PhysicsBody* b);
    
    /**
     * PhysicsShape 是 PhysicsBody's 的朋友类, 但是所有的子类不是.所以这种方法用于子类从 PhysicsBody 获取 bodyInfo.
     */
    PhysicsBodyInfo* bodyInfo(PhysicsBody* body) const;
    
protected:
    PhysicsBody* _bodyA;
    PhysicsBody* _bodyB;
    PhysicsJointInfo* _info;
    
    friend class PhysicsBody;
};

/*
 * @brief 将两个机构在一个固定的融合点. 固定接头是非常有用的,它可以用于创建复杂的图形,他也可以被打散
 */
class PhysicsJointFixed : public PhysicsJoint
{
public:
    PhysicsJointFixed* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
    
protected:
    bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
    
protected:
    PhysicsJointFixed();
    virtual ~PhysicsJointFixed();
};

/*
 * @brief 滑动联合,允许两个机构沿选定的轴滑动
 */
class PhysicsJointSliding : public PhysicsJoint
{
public:
    PhysicsJointSliding* create(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
    
protected:
    bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
    
protected:
    PhysicsJointSliding();
    virtual ~PhysicsJointSliding();
};

/*
 * @brief 弹簧节点,连接两个机构,弹簧的长度是这两个机构之间的初始距离.
 */
class PhysicsJointSpring : public PhysicsJoint
{
public:
    PhysicsJointSpring* create();
    
protected:
    bool init();
    
protected:
    PhysicsJointSpring();
    virtual ~PhysicsJointSpring();
};

/*
 * @brief 限制联合,如果它们是用绳子连接,限制这两个机构之间的最大距离.
 */
class PhysicsJointLimit : public PhysicsJoint
{
public:
    PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max);
    
protected:
    bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max);
    
protected:
    PhysicsJointLimit();
    virtual ~PhysicsJointLimit();
};

/*
 * @brief 别针联合,如果两个机构固定在一起它们可以独立绕锚点运动.
 */
class PhysicsJointPin : public PhysicsJoint
{
public:
    static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
    
protected:
    bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
    
protected:
    PhysicsJointPin();
    virtual ~PhysicsJointPin();
};

NS_CC_END

#endif // __CCPHYSICS_JOINT_H__

#endif // CC_USE_PHYSICS


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值