2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
|
|
|
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
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
|
|
|
|
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event);
|
2015-06-08 11:06:02 +08:00
|
|
|
private:
|
|
|
|
int m_entryID;
|
|
|
|
cocos2d::EventListenerTouchOneByOne* _touchListener;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TestEntry;
|
|
|
|
class Test;
|
2015-04-09 08:37:30 +08:00
|
|
|
class Box2DView : public cocos2d::Layer
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerTouchOneByOne* _touchListener;
|
|
|
|
cocos2d::EventListenerKeyboard* _keyboardListener;
|
2012-04-19 14:35:52 +08:00
|
|
|
TestEntry* m_entry;
|
|
|
|
Test* m_test;
|
|
|
|
int m_entryID;
|
|
|
|
public:
|
2019-07-22 09:38:46 +08:00
|
|
|
Box2DView();
|
|
|
|
virtual ~Box2DView();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
bool initWithEntryID(int entryId);
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string title() const;
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::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();
|
2015-07-15 12:04:48 +08:00
|
|
|
bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)override;
|
|
|
|
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event)override;
|
|
|
|
void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event)override;
|
2014-03-31 12:07:21 +08:00
|
|
|
|
2015-07-15 12:04:48 +08:00
|
|
|
void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event)override;
|
|
|
|
void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event)override;
|
2015-04-09 08:37:30 +08:00
|
|
|
//virtual void accelerometer(UIAccelerometer* accelerometer, cocos2d::Acceleration* acceleration);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
static Box2DView* viewWithEntryID(int entryId);
|
2013-12-26 15:48:26 +08:00
|
|
|
protected:
|
2015-04-09 08:37:30 +08:00
|
|
|
void onDraw(const cocos2d::Mat4& transform, uint32_t flags);
|
2014-03-06 07:49:08 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::CustomCommand _customCmd;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|