2012-04-19 14:35:52 +08:00
|
|
|
#ifndef _BOX2D_TEST_H_
|
|
|
|
#define _BOX2D_TEST_H_
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "Box2D/Box2D.h"
|
|
|
|
#include "../testBasic.h"
|
|
|
|
|
|
|
|
class PhysicsSprite : public CCSprite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PhysicsSprite();
|
|
|
|
void setPhysicsBody(b2Body * body);
|
|
|
|
virtual bool isDirty(void);
|
|
|
|
virtual CCAffineTransform nodeToParentTransform(void);
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
b2Body* _body; // strong ref
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2010-09-14 14:47:12 +08:00
|
|
|
class Box2DTestLayer : public CCLayer
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCTexture2D* _spriteTexture; // weak ref
|
2012-04-19 14:35:52 +08:00
|
|
|
b2World* world;
|
2013-06-15 14:03:30 +08:00
|
|
|
// GLESDebugDraw* _debugDraw;
|
2010-09-14 14:47:12 +08:00
|
|
|
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
Box2DTestLayer();
|
|
|
|
~Box2DTestLayer();
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void initPhysics();
|
|
|
|
void createResetButton();
|
|
|
|
virtual void draw();
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void addNewSpriteAtPosition(CCPoint p);
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void ccTouchesEnded(CCSet* touches, CCEvent* event);
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//CREATE_NODE(Box2DTestLayer);
|
2010-09-14 14:47:12 +08:00
|
|
|
} ;
|
|
|
|
|
|
|
|
class Box2DTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|