2013-06-06 12:02:54 +08:00
|
|
|
#ifndef __HELLOWORLD_SCENE_H__
|
|
|
|
#define __HELLOWORLD_SCENE_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/cocos-ext.h"
|
2013-06-06 12:02:54 +08:00
|
|
|
#include "../../VisibleRect.h"
|
|
|
|
#include "../../testBasic.h"
|
2013-10-16 11:19:01 +08:00
|
|
|
#include "cocostudio/CocoStudio.h"
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT
|
|
|
|
#include "../../Box2DTestBed/GLES-Render.h"
|
|
|
|
#include "Box2D/Box2D.h"
|
|
|
|
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
|
|
|
#include "chipmunk.h"
|
|
|
|
#endif
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
class ArmatureTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ArmatureTestScene(bool bPortrait = false);
|
|
|
|
|
|
|
|
virtual void runThisTest();
|
|
|
|
|
|
|
|
// The CallBack for back to the main menu scene
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void MainMenuCallback(Object* pSender);
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2013-09-13 18:07:37 +08:00
|
|
|
TEST_ASYNCHRONOUS_LOADING = 0,
|
2013-10-31 17:28:14 +08:00
|
|
|
TEST_DIRECT_LOADING,
|
2013-09-13 18:07:37 +08:00
|
|
|
TEST_COCOSTUDIO_WITH_SKELETON,
|
2013-06-08 22:08:22 +08:00
|
|
|
TEST_DRAGON_BONES_2_0,
|
2013-06-06 12:02:54 +08:00
|
|
|
TEST_PERFORMANCE,
|
2013-10-30 09:41:40 +08:00
|
|
|
TEST_PERFORMANCE_BATCHNODE,
|
2013-06-06 12:02:54 +08:00
|
|
|
TEST_CHANGE_ZORDER,
|
|
|
|
TEST_ANIMATION_EVENT,
|
2013-10-31 17:28:14 +08:00
|
|
|
TEST_FRAME_EVENT,
|
2013-06-06 12:02:54 +08:00
|
|
|
TEST_PARTICLE_DISPLAY,
|
|
|
|
TEST_USE_DIFFERENT_PICTURE,
|
2013-12-06 13:40:49 +08:00
|
|
|
TEST_COLLIDER_DETECTOR,
|
2013-06-06 12:02:54 +08:00
|
|
|
TEST_BOUDINGBOX,
|
|
|
|
TEST_ANCHORPOINT,
|
|
|
|
TEST_ARMATURE_NESTING,
|
2013-10-30 09:41:40 +08:00
|
|
|
TEST_ARMATURE_NESTING_2,
|
2013-12-06 13:40:49 +08:00
|
|
|
TEST_PLAY_SEVERAL_MOVEMENT,
|
|
|
|
TEST_EASING,
|
2013-12-13 15:58:58 +08:00
|
|
|
TEST_CHANGE_ANIMATION_INTERNAL,
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
TEST_LAYER_COUNT
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ArmatureTestLayer : public Layer
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void restartCallback(Object* pSender);
|
|
|
|
virtual void nextCallback(Object* pSender);
|
|
|
|
virtual void backCallback(Object* pSender);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
virtual void draw();
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
protected:
|
|
|
|
MenuItemImage *restartItem;
|
|
|
|
MenuItemImage *nextItem;
|
|
|
|
MenuItemImage *backItem;
|
|
|
|
};
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
class TestAsynchronousLoading : public ArmatureTestLayer
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual std::string subtitle();
|
2013-11-05 19:53:38 +08:00
|
|
|
virtual void restartCallback(Object* pSender);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
void dataLoaded(float percent);
|
|
|
|
};
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-10-31 17:28:14 +08:00
|
|
|
class TestDirectLoading : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
};
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
class TestCSWithSkeleton : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
};
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
class TestDragonBones20 : public ArmatureTestLayer
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
public:
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TestPerformance : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~TestPerformance();
|
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
2013-10-30 09:41:40 +08:00
|
|
|
virtual void onIncrease(Object* pSender);
|
|
|
|
virtual void onDecrease(Object* pSender);
|
|
|
|
virtual void addArmature(int number);
|
|
|
|
virtual void addArmatureToParent(cocostudio::Armature *armature);
|
|
|
|
virtual void removeArmatureFromParent(int tag);
|
|
|
|
virtual void refreshTitile();
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
int armatureCount;
|
|
|
|
|
|
|
|
int frames;
|
|
|
|
float times;
|
|
|
|
float lastTimes;
|
|
|
|
bool generated;
|
|
|
|
};
|
|
|
|
|
2013-10-30 09:41:40 +08:00
|
|
|
class TestPerformanceBatchNode : public TestPerformance
|
|
|
|
{
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual void addArmatureToParent(cocostudio::Armature *armature);
|
|
|
|
virtual void removeArmatureFromParent(int tag);
|
|
|
|
|
|
|
|
cocostudio::BatchNode *batchNode;
|
|
|
|
};
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
class TestChangeZorder : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
void changeZorder(float dt);
|
|
|
|
|
|
|
|
int currentTag;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
class TestAnimationEvent : public ArmatureTestLayer
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
2013-10-15 18:00:03 +08:00
|
|
|
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const char *movementID);
|
2013-06-06 12:02:54 +08:00
|
|
|
void callback1();
|
|
|
|
void callback2();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
2013-10-31 17:28:14 +08:00
|
|
|
|
|
|
|
class TestFrameEvent : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
|
|
|
void checkAction(float dt);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
class TestUseMutiplePicture : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
virtual void onEnter();
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void onExit();
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
int displayIndex;
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestParticleDisplay : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
virtual void onEnter();
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void onExit();
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
int animationID;
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT
|
|
|
|
|
|
|
|
class ContactListener;
|
|
|
|
|
|
|
|
class TestColliderDetector : public ArmatureTestLayer
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-09-13 18:07:37 +08:00
|
|
|
~TestColliderDetector();
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual void onEnter();
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void onExit();
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual void draw();
|
|
|
|
virtual void update(float delta);
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
void initWorld();
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
|
|
|
cocostudio::Armature *armature2;
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
cocos2d::extension::PhysicsSprite *bullet;
|
|
|
|
|
|
|
|
b2World *world;
|
|
|
|
ContactListener *listener;
|
|
|
|
GLESDebugDraw *debugDraw;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
|
|
|
|
|
|
|
|
|
|
|
class TestColliderDetector : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~TestColliderDetector();
|
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual void update(float delta);
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
void initWorld();
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
|
|
|
cocostudio::Armature *armature2;
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
cocos2d::extension::PhysicsSprite *bullet;
|
|
|
|
|
|
|
|
|
|
|
|
cpSpace *space;
|
|
|
|
|
|
|
|
static int beginHit(cpArbiter *arb, cpSpace *space, void *unused);
|
|
|
|
static void endHit(cpArbiter *arb, cpSpace *space, void *unused);
|
|
|
|
|
|
|
|
void destroyCPBody(cpBody *body);
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
2013-12-06 13:40:49 +08:00
|
|
|
#elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
|
|
|
class TestColliderDetector : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~TestColliderDetector();
|
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual void update(float delta);
|
|
|
|
virtual void draw();
|
|
|
|
|
|
|
|
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
|
|
|
|
|
|
|
void initWorld() {};
|
|
|
|
cocostudio::Armature *armature;
|
|
|
|
cocostudio::Armature *armature2;
|
|
|
|
|
|
|
|
cocos2d::Sprite *bullet;
|
|
|
|
};
|
2013-09-13 18:07:37 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
class TestBoundingBox : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual void draw();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
2013-06-20 14:17:10 +08:00
|
|
|
Rect rect;
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestAnchorPoint : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestArmatureNesting : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
2013-09-13 18:07:37 +08:00
|
|
|
virtual void onExit();
|
2013-06-06 12:02:54 +08:00
|
|
|
virtual std::string title();
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocostudio::Armature *armature;
|
2013-06-06 12:02:54 +08:00
|
|
|
int weaponIndex;
|
|
|
|
};
|
2013-10-30 09:41:40 +08:00
|
|
|
|
|
|
|
class Hero : public cocostudio::Armature
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Hero *create(const char *name);
|
|
|
|
Hero();
|
|
|
|
|
|
|
|
virtual void changeMount(cocostudio::Armature *armature);
|
|
|
|
virtual void playByIndex(int index);
|
|
|
|
|
|
|
|
CC_SYNTHESIZE(cocostudio::Armature*, m_pMount, Mount);
|
|
|
|
CC_SYNTHESIZE(cocos2d::Layer*, m_pLayer, Layer);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestArmatureNesting2 : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
|
|
|
|
|
|
|
virtual void ChangeMountCallback(Object* pSender);
|
|
|
|
virtual cocostudio::Armature *createMount(const char *name, Point position);
|
|
|
|
|
|
|
|
Hero *hero;
|
|
|
|
|
|
|
|
cocostudio::Armature *horse;
|
|
|
|
cocostudio::Armature *horse2;
|
|
|
|
cocostudio::Armature *bear;
|
|
|
|
|
|
|
|
|
|
|
|
bool touchedMenu;
|
|
|
|
};
|
2013-12-06 13:40:49 +08:00
|
|
|
|
|
|
|
class TestPlaySeveralMovement : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TestEasing : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
|
|
|
void updateSubTitle();
|
|
|
|
|
|
|
|
int animationID;
|
|
|
|
cocostudio::Armature *armature;
|
|
|
|
};
|
|
|
|
|
2013-12-13 15:58:58 +08:00
|
|
|
class TestChangeAnimationInternal : public ArmatureTestLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
|
|
|
};
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
#endif // __HELLOWORLD_SCENE_H__
|