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-05-31 07:42:05 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void addNewSpriteAtPosition(Vec2 p);
|
2015-03-15 02:33:15 +08:00
|
|
|
void update(float dt) override;
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event) override;
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2013-12-25 10:54:31 +08:00
|
|
|
#if CC_ENABLE_BOX2D_INTEGRATION
|
|
|
|
protected:
|
2014-05-15 01:07:09 +08:00
|
|
|
Mat4 _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
|