cocos2d-x节点(CCPhysicsWorld.h)API
来源:互联网 发布:win7不能启用网络发现 编辑:程序博客网 时间:2024/05/21 17:02
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(CCPhysicsWorld.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
//添加移除物理世界关联
///cocos2d-x-3.0alpha0/cocos2dx/physics//添加移除物理世界关联#include "CCPhysicsSetting.h"#ifdef CC_USE_PHYSICS#ifndef __CCPHYSICS_WORLD_H__#define __CCPHYSICS_WORLD_H__#include "cocoa/CCObject.h"#include "cocoa/CCGeometry.h"#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)typedef struct cpArbiter cpArbiter;typedef struct cpSpace cpSpace;#endifNS_CC_BEGINclass PhysicsBody;class PhysicsJoint;class PhysicsWorldInfo;class PhysicsShape;class PhysicsContact;class PhysicsContactPreSolve;class PhysicsContactPostSolve;class PhysicsContactListener;class Array;class Sprite;class Scene;class DrawNode;/** * @brief 一个PhysicsWorld对象模拟碰撞等物理属性. 你不应该直接创建 PhysicsWorld 对象; 相反,你可以从一个 Scene 对象里面得到它. */class PhysicsWorld{public: /** 添加一个物理世界的关联.*/ void addJoint(PhysicsJoint* joint); /** 移除一个物理世界的关联.*/ void removeJoint(PhysicsJoint* joint); /** 移除所有物理世界的关联.*/ void removeAllJoints(); Array* getBodysAlongRay(Point start, Point end) const; Array* getBodysAtPoint(Point point) const; Array* getBodysInRect(Rect rect) const; Array* getAllBody() const; /** 注册一个侦听器接收联系回调*/ inline void registerContactListener(PhysicsContactListener* delegate) { _listener = delegate; } /** 注销一个监听器. */ inline void unregisterContactListener() { _listener = nullptr; } /** get 重力值 */ inline Point getGravity() { return _gravity; } /** set 重力值 */ void setGravity(Point gravity); /** 启用测试调试 draw */ inline bool isDebugDraw() { return _debugDraw; } /** 设置调试 draw */ inline void setDebugDraw(bool debugDraw) { _debugDraw = debugDraw; } protected: static PhysicsWorld* create(); bool init(); void setScene(Scene* scene); virtual void addChild(PhysicsBody* body); virtual void addShape(PhysicsShape* shape); virtual void update(float delta); virtual void debugDraw(); virtual void drawWithShape(DrawNode* node, PhysicsShape* shape); virtual int collisionBeginCallback(const PhysicsContact& contact); virtual int collisionPreSolveCallback(const PhysicsContact& contact, const PhysicsContactPreSolve& solve); virtual void collisionPostSolveCallback(const PhysicsContact& contact, const PhysicsContactPostSolve& solve); virtual void collisionSeparateCallback(const PhysicsContact& contact); #if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data); static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data);#endif protected: Point _gravity; float _speed; PhysicsWorldInfo* _info; PhysicsContactListener* _listener; Array* _bodys; Scene* _scene; bool _debugDraw; DrawNode* _drawNode; protected: PhysicsWorld(); virtual ~PhysicsWorld(); friend class Sprite; friend class Scene; friend class PhysicsBody;};NS_CC_END#endif // __CCPHYSICS_WORLD_H__#endif // CC_USE_PHYSICS
- cocos2d-x节点(CCPhysicsWorld.h)API
- cocos2d-x节点(cocos2d.h)API
- cocos2d-X 节点(CCNode.h)API
- cocos2d-X 节点(CCLayer.h)API
- cocos2d-X 节点(CCMenu.h)API
- cocos2d-X 节点(CCMenuItem.h)API
- cocos2d-X 节点(CCSprite.h)API
- cocos2d-X 节点(CCTexture2D.h)API
- cocos2d-X 节点(SpriteBatchNode.h.)API
- cocos2d-X 节点(CCSpriteFrame.h..)API
- cocos2d-X 节点(CCAnimationCache.h)API
- cocos2d-X 节点(CCCamera.h.)API
- cocos2d-X 节点(CCAction.h)API
- cocos2d-X 节点(CCActionManager.h)API
- cocos2d-X 节点(CCIMEDelegate.h)API
- cocos2d-X 节点(CCLabelAtlas.h)API
- cocos2d-X 节点(CCLabelBMFont.h)API
- cocos2d-X 节点(CCLabelTTF.h)API
- cocos2d-x节点(CCPhysicsContact.h)API
- opencv学习-算法-pca
- maven-jetty导致jsf注解不可用问题Target Unreachable, identifier 'dataBean' resolved to null
- cocos2d-x节点(CCPhysicsShape.h)API
- cocos2d-x节点(CCPhysicsJoint.h)API
- cocos2d-x节点(CCPhysicsWorld.h)API
- 4.C++ 简单运算表达式
- Linux脚本编程(二)
- MyEclipse设置新的jsp默认的编码格式
- 蓝桥杯-最大数
- 我的Linux历险记-在终于玩坏了一个系统之后的总结
- hdu 3220 Alice’s Cube 逆向搜索+二进制压缩
- source insight 使用
- 程序员究竟可以干多少年