2012-04-19 14:35:52 +08:00
|
|
|
#ifndef _BOX2D_VIEW_H_
|
|
|
|
#define _BOX2D_VIEW_H_
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
#include "../BaseTest.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(Box2dTestBedSuite);
|
|
|
|
|
|
|
|
class Box2dTestBed : public TestCase
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int m_entryID;
|
2013-10-23 11:27:24 +08:00
|
|
|
EventListenerTouchOneByOne* _touchListener;
|
2012-04-19 14:35:52 +08:00
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
static Box2dTestBed* createWithEntryID(int entryId);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
Box2dTestBed();
|
|
|
|
virtual ~Box2dTestBed();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
bool initWithEntryID(int entryId);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
bool onTouchBegan(Touch* touch, Event* event);
|
|
|
|
void onTouchMoved(Touch* touch, Event* event);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TestEntry;
|
|
|
|
class Test;
|
2013-06-20 14:17:10 +08:00
|
|
|
class Box2DView : public Layer
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-10-23 11:27:24 +08:00
|
|
|
EventListenerTouchOneByOne* _touchListener;
|
2014-03-31 12:07:21 +08:00
|
|
|
EventListenerKeyboard* _keyboardListener;
|
2012-04-19 14:35:52 +08:00
|
|
|
TestEntry* m_entry;
|
|
|
|
Test* m_test;
|
|
|
|
int m_entryID;
|
|
|
|
public:
|
|
|
|
Box2DView(void);
|
|
|
|
virtual ~Box2DView(void);
|
|
|
|
|
|
|
|
bool initWithEntryID(int entryId);
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string title() const;
|
2014-05-31 07:42:05 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
// virtual void registerWithTouchDispatcher();
|
2013-10-23 16:14:03 +08:00
|
|
|
bool onTouchBegan(Touch* touch, Event* event);
|
|
|
|
void onTouchMoved(Touch* touch, Event* event);
|
|
|
|
void onTouchEnded(Touch* touch, Event* event);
|
2014-03-31 12:07:21 +08:00
|
|
|
|
|
|
|
void onKeyPressed(EventKeyboard::KeyCode code, Event* event);
|
|
|
|
void onKeyReleased(EventKeyboard::KeyCode code, Event* event);
|
2013-06-20 14:17:10 +08:00
|
|
|
//virtual void accelerometer(UIAccelerometer* accelerometer, Acceleration* acceleration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
static Box2DView* viewWithEntryID(int entryId);
|
2013-12-26 15:48:26 +08:00
|
|
|
protected:
|
2014-05-31 07:42:05 +08:00
|
|
|
void onDraw(const Mat4 &transform, uint32_t flags);
|
2014-03-06 07:49:08 +08:00
|
|
|
|
2013-12-27 14:42:45 +08:00
|
|
|
CustomCommand _customCmd;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|