2012-03-21 15:43:35 +08:00
|
|
|
//
|
|
|
|
// cocos2d
|
|
|
|
//
|
2012-11-20 16:19:05 +08:00
|
|
|
#ifndef __CHIPMUNKTEST_H__
|
|
|
|
#define __CHIPMUNKTEST_H__
|
2012-03-21 15:43:35 +08:00
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "chipmunk.h"
|
|
|
|
#include "../testBasic.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/cocos-ext.h"
|
2012-03-21 15:43:35 +08:00
|
|
|
|
2012-11-20 16:19:05 +08:00
|
|
|
USING_NS_CC_EXT;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ChipmunkTestLayer : public Layer
|
2012-03-21 15:43:35 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-11-20 16:19:05 +08:00
|
|
|
ChipmunkTestLayer();
|
|
|
|
~ChipmunkTestLayer();
|
2012-04-19 14:35:52 +08:00
|
|
|
void onEnter();
|
|
|
|
void initPhysics();
|
|
|
|
void createResetButton();
|
2014-02-20 10:53:49 +08:00
|
|
|
void reset(Ref* sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void addNewSpriteAtPosition(cocos2d::Vec2 p);
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2014-02-20 10:53:49 +08:00
|
|
|
void toggleDebugCallback(Ref* sender);
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2013-10-23 11:27:24 +08:00
|
|
|
virtual void onAcceleration(Acceleration* acc, Event* event);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-05-02 14:06:40 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D* _spriteTexture; // weak ref
|
2013-01-06 10:22:07 +08:00
|
|
|
#if CC_ENABLE_CHIPMUNK_INTEGRATION
|
2013-06-20 14:17:10 +08:00
|
|
|
PhysicsDebugNode* _debugLayer; // weak ref
|
2013-01-06 10:22:07 +08:00
|
|
|
#endif
|
2013-06-15 14:03:30 +08:00
|
|
|
cpSpace* _space; // strong ref
|
|
|
|
cpShape* _walls[4];
|
2012-03-21 15:43:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ChipmunkAccelTouchTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void runThisTest();
|
2012-03-21 15:43:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __CHIPMUNKACCELTOUCHTEST_H__ */
|