2012-04-19 14:35:52 +08:00
|
|
|
#ifndef _BOX2D_TEST_H_
|
|
|
|
#define _BOX2D_TEST_H_
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "Box2D/Box2D.h"
|
2015-04-03 14:31:03 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(Box2DTests);
|
|
|
|
|
|
|
|
class Box2DTest : public TestCase
|
2010-09-14 14:47:12 +08:00
|
|
|
{
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::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:
|
2015-04-03 14:31:03 +08:00
|
|
|
Box2DTest();
|
|
|
|
~Box2DTest();
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void initPhysics();
|
|
|
|
void createResetButton();
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
|
2010-09-14 14:47:12 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void addNewSpriteAtPosition(cocos2d::Vec2 p);
|
2015-03-15 02:33:15 +08:00
|
|
|
void update(float dt) override;
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::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-05-15 01:07:09 +08:00
|
|
|
Mat4 _modelViewMV;
|
2013-12-25 10:54:31 +08:00
|
|
|
void onDraw();
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::CustomCommand _customCommand;
|
2013-12-25 10:54:31 +08:00
|
|
|
#endif
|
2010-09-14 14:47:12 +08:00
|
|
|
} ;
|
|
|
|
|
|
|
|
#endif
|