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"
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class Box2DTestLayer : public Layer
|
2010-09-14 14:47:12 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D* _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();
|
2014-04-08 22:07:35 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2014-04-15 18:23:40 +08:00
|
|
|
void addNewSpriteAtPosition(Vector2 p);
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2013-12-25 10:54:31 +08:00
|
|
|
#if CC_ENABLE_BOX2D_INTEGRATION
|
|
|
|
protected:
|
2014-04-10 10:16:16 +08:00
|
|
|
Matrix _modelViewMV;
|
2013-12-25 10:54:31 +08:00
|
|
|
void onDraw();
|
2013-12-26 21:19:12 +08:00
|
|
|
CustomCommand _customCommand;
|
2013-12-25 10:54:31 +08:00
|
|
|
#endif
|
2010-09-14 14:47:12 +08:00
|
|
|
} ;
|
|
|
|
|
|
|
|
class Box2DTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|