Adds Base class to tests

Base class displays the Menu( <- O -> )
Improved in some tests the way to create entries.
Instead of defining the tests twice: the "create" method, and the entry
   in the array, it is only needed in the array (ActionsTest, SpriteTest
   and Texture2DTest)
This commit is contained in:
Ricardo Quesada 2013-06-06 17:12:28 -07:00
parent 698e4092ae
commit 80117afc82
43 changed files with 297 additions and 695 deletions

View File

@ -82,28 +82,6 @@ std::string ActionManagerTest::title()
return "No title"; return "No title";
} }
void ActionManagerTest::onEnter()
{
CCLayer::onEnter();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label, 1);
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&ActionManagerTest::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&ActionManagerTest::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&ActionManagerTest::nextCallback, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
addChild(menu, 1);
}
void ActionManagerTest::restartCallback(CCObject* pSender) void ActionManagerTest::restartCallback(CCObject* pSender)
{ {
CCScene* s = new ActionManagerTestScene(); CCScene* s = new ActionManagerTestScene();

View File

@ -2,8 +2,9 @@
#define _ACTION_MANAGER_TEST_H_ #define _ACTION_MANAGER_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class ActionManagerTest: public CCLayer class ActionManagerTest: public BaseTest
{ {
protected: protected:
CCTextureAtlas* m_atlas; CCTextureAtlas* m_atlas;
@ -15,7 +16,6 @@ public:
~ActionManagerTest(void); ~ActionManagerTest(void);
virtual std::string title(); virtual std::string title();
virtual void onEnter();
void restartCallback(CCObject* pSender); void restartCallback(CCObject* pSender);
void nextCallback(CCObject* pSender); void nextCallback(CCObject* pSender);

View File

@ -606,7 +606,7 @@ std::string EaseSpriteDemo::title()
void EaseSpriteDemo::onEnter() void EaseSpriteDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too // Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain(); m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain();
@ -620,23 +620,6 @@ void EaseSpriteDemo::onEnter()
m_grossini->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5)); m_grossini->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5));
m_kathia->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5)); m_kathia->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5));
m_tamara->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); m_tamara->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5));
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&EaseSpriteDemo::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&EaseSpriteDemo::restartCallback , this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&EaseSpriteDemo::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
addChild(menu, 1);
} }
void EaseSpriteDemo::restartCallback(CCObject* pSender) void EaseSpriteDemo::restartCallback(CCObject* pSender)

View File

@ -3,10 +3,11 @@
////----#include "cocos2d.h" ////----#include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
USING_NS_CC; USING_NS_CC;
class EaseSpriteDemo : public CCLayer class EaseSpriteDemo : public BaseTest
{ {
protected: protected:
CCSprite* m_grossini; CCSprite* m_grossini;

View File

@ -90,32 +90,7 @@ std::string SpriteDemo::subtitle()
void SpriteDemo::onEnter() void SpriteDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22);
addChild(l, 1);
l->setPosition( ccp(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255)); CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255));
addChild(background, -10); addChild(background, -10);

View File

@ -2,8 +2,9 @@
#define _ACTIONS_PROGRESS_TEST_H_ #define _ACTIONS_PROGRESS_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class SpriteDemo : public CCLayer class SpriteDemo : public BaseTest
{ {
public: public:
SpriteDemo(void); SpriteDemo(void);

View File

@ -2,101 +2,53 @@
#include "../testResource.h" #include "../testResource.h"
#include "cocos2d.h" #include "cocos2d.h"
TESTLAYER_CREATE_FUNC(ActionManual); static std::function<CCLayer*()> createFunctions[] = {
TESTLAYER_CREATE_FUNC(ActionMove); CL(ActionManual),
TESTLAYER_CREATE_FUNC(ActionRotate); CL(ActionMove),
TESTLAYER_CREATE_FUNC(ActionScale); CL(ActionRotate),
TESTLAYER_CREATE_FUNC(ActionSkew); CL(ActionScale),
TESTLAYER_CREATE_FUNC(ActionRotationalSkew); CL(ActionSkew),
TESTLAYER_CREATE_FUNC(ActionRotationalSkewVSStandardSkew); CL(ActionRotationalSkew),
TESTLAYER_CREATE_FUNC(ActionSkewRotateScale); CL(ActionRotationalSkewVSStandardSkew),
TESTLAYER_CREATE_FUNC(ActionJump); CL(ActionSkewRotateScale),
TESTLAYER_CREATE_FUNC(ActionCardinalSpline); CL(ActionJump),
TESTLAYER_CREATE_FUNC(ActionCatmullRom); CL(ActionCardinalSpline),
TESTLAYER_CREATE_FUNC(ActionBezier); CL(ActionCatmullRom),
TESTLAYER_CREATE_FUNC(ActionBlink); CL(ActionBezier),
TESTLAYER_CREATE_FUNC(ActionFade); CL(ActionBlink),
TESTLAYER_CREATE_FUNC(ActionTint); CL(ActionFade),
TESTLAYER_CREATE_FUNC(ActionAnimate); CL(ActionTint),
TESTLAYER_CREATE_FUNC(ActionSequence); CL(ActionAnimate),
TESTLAYER_CREATE_FUNC(ActionSequence2); CL(ActionSequence),
TESTLAYER_CREATE_FUNC(ActionSpawn); CL(ActionSequence2),
TESTLAYER_CREATE_FUNC(ActionReverse); CL(ActionRemoveSelf),
TESTLAYER_CREATE_FUNC(ActionDelayTime); CL(ActionSpawn),
TESTLAYER_CREATE_FUNC(ActionRepeat); CL(ActionReverse),
TESTLAYER_CREATE_FUNC(ActionRepeatForever); CL(ActionDelayTime),
TESTLAYER_CREATE_FUNC(ActionRotateToRepeat); CL(ActionRepeat),
TESTLAYER_CREATE_FUNC(ActionRotateJerk); CL(ActionRepeatForever),
TESTLAYER_CREATE_FUNC(ActionCallFunction); CL(ActionRotateToRepeat),
TESTLAYER_CREATE_FUNC(ActionCallFunc); CL(ActionRotateJerk),
TESTLAYER_CREATE_FUNC(ActionCallFuncND); CL(ActionCallFunction),
TESTLAYER_CREATE_FUNC(ActionReverseSequence); CL(ActionCallFunc),
TESTLAYER_CREATE_FUNC(ActionReverseSequence2); CL(ActionCallFuncND),
TESTLAYER_CREATE_FUNC(ActionRemoveSelf); CL(ActionReverseSequence),
TESTLAYER_CREATE_FUNC(ActionOrbit); CL(ActionReverseSequence2),
TESTLAYER_CREATE_FUNC(ActionFollow); CL(ActionOrbit),
TESTLAYER_CREATE_FUNC(ActionTargeted); CL(ActionFollow),
TESTLAYER_CREATE_FUNC(ActionMoveStacked); CL(ActionTargeted),
TESTLAYER_CREATE_FUNC(ActionMoveJumpStacked); CL(ActionMoveStacked),
TESTLAYER_CREATE_FUNC(ActionMoveBezierStacked); CL(ActionMoveJumpStacked),
TESTLAYER_CREATE_FUNC(ActionCardinalSplineStacked); CL(ActionMoveBezierStacked),
TESTLAYER_CREATE_FUNC(ActionCatmullRomStacked); CL(ActionCardinalSplineStacked),
TESTLAYER_CREATE_FUNC(PauseResumeActions); CL(ActionCatmullRomStacked),
TESTLAYER_CREATE_FUNC(Issue1305); CL(PauseResumeActions),
TESTLAYER_CREATE_FUNC(Issue1305_2); CL(Issue1305),
TESTLAYER_CREATE_FUNC(Issue1288); CL(Issue1305_2),
TESTLAYER_CREATE_FUNC(Issue1288_2); CL(Issue1288),
TESTLAYER_CREATE_FUNC(Issue1327); CL(Issue1288_2),
TESTLAYER_CREATE_FUNC(Issue1398); CL(Issue1327),
CL(Issue1398)
static NEWTESTFUNC createFunctions[] = {
CF(ActionManual),
CF(ActionMove),
CF(ActionRotate),
CF(ActionScale),
CF(ActionSkew),
CF(ActionRotationalSkew),
CF(ActionRotationalSkewVSStandardSkew),
CF(ActionSkewRotateScale),
CF(ActionJump),
CF(ActionCardinalSpline),
CF(ActionCatmullRom),
CF(ActionBezier),
CF(ActionBlink),
CF(ActionFade),
CF(ActionTint),
CF(ActionAnimate),
CF(ActionSequence),
CF(ActionSequence2),
CF(ActionRemoveSelf),
CF(ActionSpawn),
CF(ActionReverse),
CF(ActionDelayTime),
CF(ActionRepeat),
CF(ActionRepeatForever),
CF(ActionRotateToRepeat),
CF(ActionRotateJerk),
CF(ActionCallFunction),
CF(ActionCallFunc),
CF(ActionCallFuncND),
CF(ActionReverseSequence),
CF(ActionReverseSequence2),
CF(ActionOrbit),
CF(ActionFollow),
CF(ActionTargeted),
CF(ActionMoveStacked),
CF(ActionMoveJumpStacked),
CF(ActionMoveBezierStacked),
CF(ActionCardinalSplineStacked),
CF(ActionCatmullRomStacked),
CF(PauseResumeActions),
CF(Issue1305),
CF(Issue1305_2),
CF(Issue1288),
CF(Issue1288_2),
CF(Issue1327),
CF(Issue1398)
}; };
static int sceneIdx=-1; static int sceneIdx=-1;
@ -158,7 +110,7 @@ std::string ActionsDemo::subtitle()
void ActionsDemo::onEnter() void ActionsDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
m_grossini = CCSprite::create(s_pPathGrossini); m_grossini = CCSprite::create(s_pPathGrossini);
@ -177,35 +129,6 @@ void ActionsDemo::onEnter()
m_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3)); m_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3));
m_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3)); m_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3));
m_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2)); m_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2));
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &ActionsDemo::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &ActionsDemo::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &ActionsDemo::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void ActionsDemo::onExit() void ActionsDemo::onExit()
@ -214,7 +137,7 @@ void ActionsDemo::onExit()
m_tamara->release(); m_tamara->release();
m_kathia->release(); m_kathia->release();
CCLayer::onExit(); BaseTest::onExit();
} }
void ActionsDemo::restartCallback(CCObject* pSender) void ActionsDemo::restartCallback(CCObject* pSender)

View File

@ -2,6 +2,7 @@
#define _ActionsTest_H_ #define _ActionsTest_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
////----#include "cocos2d.h" ////----#include "cocos2d.h"
USING_NS_CC; USING_NS_CC;
@ -63,7 +64,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class ActionsDemo : public CCLayer class ActionsDemo : public BaseTest
{ {
protected: protected:
CCSprite* m_grossini; CCSprite* m_grossini;

View File

@ -0,0 +1,79 @@
//
// BaseTest.cpp
// TestCpp
//
// Created by Ricardo Quesada on 6/6/13.
//
//
#include "BaseTest.h"
#include "VisibleRect.h"
#include "testResource.h"
USING_NS_CC;
void BaseTest::onEnter()
{
CCLayer::onEnter();
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &BaseTest::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &BaseTest::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &BaseTest::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
}
void BaseTest::onExit()
{
CCLayer::onExit();
}
std::string BaseTest::title()
{
return "";
}
std::string BaseTest::subtitle()
{
return "";
}
void BaseTest::restartCallback(CCObject* pSender)
{
CCLog("override restart!");
}
void BaseTest::nextCallback(CCObject* pSender)
{
CCLog("override next!");
}
void BaseTest::backCallback(CCObject* pSender)
{
CCLog("override back!");
}

View File

@ -0,0 +1,29 @@
//
// BaseTest.h
// TestCpp
//
// Created by Ricardo Quesada on 6/6/13.
//
//
#ifndef __TestCpp__BaseTest__
#define __TestCpp__BaseTest__
#include "cocos2d.h"
class BaseTest : public cocos2d::CCLayer
{
public:
virtual void onEnter();
virtual void onExit();
virtual std::string title();
virtual std::string subtitle();
virtual void restartCallback(CCObject* pSender);
virtual void nextCallback(CCObject* pSender);
virtual void backCallback(CCObject* pSender);
};
#endif /* defined(__TestCpp__BaseTest__) */

View File

@ -92,40 +92,13 @@ static CCLayer* restartAction()
bool BaseClippingNodeTest::init() bool BaseClippingNodeTest::init()
{ {
if (CCLayer::init()) { if (BaseTest::init()) {
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite *background = CCSprite::create(s_back3); CCSprite *background = CCSprite::create(s_back3);
background->setAnchorPoint( CCPointZero ); background->setAnchorPoint( CCPointZero );
background->setPosition( CCPointZero ); background->setPosition( CCPointZero );
this->addChild(background, -1); this->addChild(background, -1);
CCLabelTTF *label = CCLabelTTF::create(this->title().c_str(), "Arial", 32);
this->addChild(label, 1, kTagTitleLabel);
label->setPosition( ccp(s.width / 2, s.height - 50));
std::string subtitleText = this->subtitle();
if (subtitleText.length() > 0) {
CCLabelTTF *subtitle = CCLabelTTF::create(subtitleText.c_str(), "Thonburi", 16);
this->addChild(subtitle, 1, kTagSubtitleLabel);
subtitle->setPosition(ccp(s.width / 2, s.height - 80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2,
this, menu_selector(BaseClippingNodeTest::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2,
this, menu_selector(BaseClippingNodeTest::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2,
this, menu_selector(BaseClippingNodeTest::nextCallback));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( ccp(s.width / 2 - item2->getContentSize().width * 2, item2->getContentSize().height / 2));
item2->setPosition( ccp(s.width / 2, item2->getContentSize().height / 2));
item3->setPosition( ccp(s.width / 2 + item2->getContentSize().width * 2, item2->getContentSize().height / 2));
this->addChild(menu, 1);
this->setup(); this->setup();
return true; return true;
} }

View File

@ -2,8 +2,9 @@
#define __CLIPPINGNODETEST_H__ #define __CLIPPINGNODETEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class BaseClippingNodeTest : public CCLayer class BaseClippingNodeTest : public BaseTest
{ {
public: public:
~BaseClippingNodeTest(); ~BaseClippingNodeTest();

View File

@ -76,41 +76,12 @@ std::string ConfigurationBase::subtitle()
void ConfigurationBase::onEnter() void ConfigurationBase::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ConfigurationBase::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ConfigurationBase::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ConfigurationBase::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void ConfigurationBase::onExit() void ConfigurationBase::onExit()
{ {
CCLayer::onExit(); BaseTest::onExit();
} }
void ConfigurationBase::restartCallback(CCObject* pSender) void ConfigurationBase::restartCallback(CCObject* pSender)

View File

@ -2,6 +2,7 @@
#define __CONFIGURATIONTEST_H__ #define __CONFIGURATIONTEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
USING_NS_CC; USING_NS_CC;
@ -15,7 +16,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class ConfigurationBase : public CCLayer class ConfigurationBase : public BaseTest
{ {
protected: protected:

View File

@ -66,33 +66,7 @@ BaseLayer::BaseLayer()
void BaseLayer::onEnter() void BaseLayer::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition(ccp(s.width/2, s.height-50));
string subTitle = subtitle();
if (subTitle.size() > 0)
{
CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width/2, s.height-80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(BaseLayer::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(BaseLayer::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(BaseLayer::nextCallback));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(ccp(s.width/2, item2->getContentSize().height/2));
item3->setPosition(ccp(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 100);
} }
void BaseLayer::restartCallback(cocos2d::CCObject *pSender) void BaseLayer::restartCallback(cocos2d::CCObject *pSender)

View File

@ -3,10 +3,11 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
#include <string> #include <string>
class BaseLayer : public CCLayer class BaseLayer : public BaseTest
{ {
public: public:
BaseLayer(); BaseLayer();

View File

@ -333,7 +333,7 @@ CCLayer* restartEffectAdvanceAction()
void EffectAdvanceTextLayer::onEnter(void) void EffectAdvanceTextLayer::onEnter(void)
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSprite *bg = CCSprite::create("Images/background3.png"); CCSprite *bg = CCSprite::create("Images/background3.png");
addChild(bg, 0, kTagBackground); addChild(bg, 0, kTagBackground);
@ -351,34 +351,7 @@ void EffectAdvanceTextLayer::onEnter(void)
tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
CCActionInterval* sc2 = CCScaleBy::create(2, 5); CCActionInterval* sc2 = CCScaleBy::create(2, 5);
CCActionInterval* sc2_back = sc2->reverse(); CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) ); tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) );
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 101);
l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void) EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)

View File

@ -3,8 +3,9 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class EffectAdvanceTextLayer: public CCLayer class EffectAdvanceTextLayer: public BaseTest
{ {
protected: protected:
CCTextureAtlas* m_atlas; CCTextureAtlas* m_atlas;

View File

@ -337,8 +337,10 @@ void EffectTestScene::runThisTest()
#define SID_RESTART 1 #define SID_RESTART 1
TextLayer::TextLayer(void) TextLayer::TextLayer(void)
: BaseTest::BaseTest()
{ {
initWithColor( ccc4(32,128,32,255) ); CCLayerColor *background = CCLayerColor::create( ccc4(32,128,32,255) );
this->addChild(background,-20);
CCNode* node = CCNode::create(); CCNode* node = CCNode::create();
CCActionInterval* effect = getAction(); CCActionInterval* effect = getAction();
@ -364,25 +366,6 @@ TextLayer::TextLayer(void)
CCActionInterval* sc2_back = sc2->reverse(); CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) ); tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
schedule( schedule_selector(TextLayer::checkAnim) ); schedule( schedule_selector(TextLayer::checkAnim) );
} }
@ -413,7 +396,7 @@ TextLayer* TextLayer::create()
void TextLayer::onEnter() void TextLayer::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
} }
void TextLayer::newScene() void TextLayer::newScene()

View File

@ -2,6 +2,7 @@
#define _EFFECTS_TEST_H_ #define _EFFECTS_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class EffectTestScene : public TestScene class EffectTestScene : public TestScene
{ {
@ -9,7 +10,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class TextLayer : public CCLayerColor class TextLayer : public BaseTest
{ {
protected: protected:
//UxString m_strTitle; //UxString m_strTitle;

View File

@ -65,31 +65,7 @@ void FileUtilsTestScene::runThisTest()
void FileUtilsDemo::onEnter() void FileUtilsDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
std::string subTitle = subtitle();
if(! subTitle.empty())
{
CCLabelTTF* l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(FileUtilsDemo::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(FileUtilsDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(FileUtilsDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void FileUtilsDemo::backCallback(CCObject* pSender) void FileUtilsDemo::backCallback(CCObject* pSender)

View File

@ -2,6 +2,8 @@
#define __FILEUTILSTEST_H__ #define __FILEUTILSTEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
USING_NS_CC; USING_NS_CC;
using namespace std; using namespace std;
@ -11,7 +13,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class FileUtilsDemo : public CCLayer class FileUtilsDemo : public BaseTest
{ {
public: public:
virtual void onEnter(); virtual void onEnter();

View File

@ -77,18 +77,8 @@ static const char* restartAction(void)
FontTest::FontTest() FontTest::FontTest()
: BaseTest()
{ {
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
showFont(restartAction()); showFont(restartAction());
} }

View File

@ -3,6 +3,7 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class FontTestScene : public TestScene class FontTestScene : public TestScene
{ {
@ -10,7 +11,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class FontTest : public cocos2d::CCLayer class FontTest : public BaseTest
{ {
public: public:
FontTest(); FontTest();

View File

@ -134,34 +134,7 @@ std::string AtlasDemo::subtitle()
void AtlasDemo::onEnter() void AtlasDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(AtlasDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(AtlasDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(AtlasDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));;
addChild(menu, 1);
} }
void AtlasDemo::restartCallback(CCObject* pSender) void AtlasDemo::restartCallback(CCObject* pSender)

View File

@ -2,8 +2,9 @@
#define _ATLAS_TEST_H_ #define _ATLAS_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class AtlasDemo : public CCLayer class AtlasDemo : public BaseTest
{ {
protected: protected:

View File

@ -99,34 +99,7 @@ std::string LayerTest::title()
void LayerTest::onEnter() void LayerTest::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
string subtitle_ = subtitle();
if (subtitle_.size() > 0)
{
CCLabelTTF *l = CCLabelTTF::create(subtitle_.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width / 2, s.height - 80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(LayerTest::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(LayerTest::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(LayerTest::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void LayerTest::restartCallback(CCObject* pSender) void LayerTest::restartCallback(CCObject* pSender)

View File

@ -3,8 +3,9 @@
////----#include "cocos2d.h" ////----#include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class LayerTest : public CCLayer class LayerTest : public BaseTest
{ {
protected: protected:
std::string m_strTitle; std::string m_strTitle;

View File

@ -228,36 +228,11 @@ std::string MotionStreakTest::subtitle()
void MotionStreakTest::onEnter() void MotionStreakTest::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); CCMenuItemToggle *itemMode = CCMenuItemToggle::createWithCallback( std::bind(&MotionStreakTest::modeCallback, this, std::placeholders::_1),
addChild(label, 0, kTagLabel);
label->setPosition(ccp(s.width/2, s.height-50));
string subTitle = this->subtitle();
if (subTitle.size() > 0)
{
CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width/2, s.height-80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(MotionStreakTest::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
CCMenuItemToggle *itemMode = CCMenuItemToggle::createWithTarget(this, menu_selector(MotionStreakTest::modeCallback),
CCMenuItemFont::create("Use High Quality Mode"), CCMenuItemFont::create("Use High Quality Mode"),
CCMenuItemFont::create("Use Fast Mode"), CCMenuItemFont::create("Use Fast Mode"),
NULL); NULL);

View File

@ -3,10 +3,11 @@
////----#include "cocos2d.h" ////----#include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
//USING_NS_CC; //USING_NS_CC;
class MotionStreakTest : public CCLayer class MotionStreakTest : public BaseTest
{ {
public: public:
MotionStreakTest(void); MotionStreakTest(void);

View File

@ -100,34 +100,7 @@ std::string TestCocosNodeDemo::subtitle()
void TestCocosNodeDemo::onEnter() void TestCocosNodeDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label, 10);
label->setPosition( ccp(s.width/2, s.height-50) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestCocosNodeDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1,s_pPathR2, this, menu_selector(TestCocosNodeDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestCocosNodeDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 11);
} }
void TestCocosNodeDemo::restartCallback(CCObject* pSender) void TestCocosNodeDemo::restartCallback(CCObject* pSender)

View File

@ -3,8 +3,9 @@
////----#include "cocos2d.h" ////----#include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class TestCocosNodeDemo : public CCLayer class TestCocosNodeDemo : public BaseTest
{ {
public: public:
TestCocosNodeDemo(void); TestCocosNodeDemo(void);

View File

@ -216,26 +216,7 @@ std::string ParallaxDemo::title()
void ParallaxDemo::onEnter() void ParallaxDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ParallaxDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ParallaxDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ParallaxDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void ParallaxDemo::restartCallback(CCObject* pSender) void ParallaxDemo::restartCallback(CCObject* pSender)

View File

@ -2,8 +2,9 @@
#define _PARALLAX_TEST_H_ #define _PARALLAX_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class ParallaxDemo : public CCLayer class ParallaxDemo : public BaseTest
{ {
protected: protected:
CCTextureAtlas* m_atlas; CCTextureAtlas* m_atlas;

View File

@ -640,7 +640,7 @@ void RadiusMode1::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -724,7 +724,7 @@ void RadiusMode2::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -808,7 +808,7 @@ void Issue704::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -900,7 +900,7 @@ void Issue870::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -941,7 +941,7 @@ void DemoParticleFromFile::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1067,41 +1067,26 @@ ParticleDemo::~ParticleDemo(void)
void ParticleDemo::onEnter(void) void ParticleDemo::onEnter(void)
{ {
CCLayer::onEnter(); BaseTest::onEnter();
initWithColor( ccc4(127,127,127,255) ); m_color = CCLayerColor::create( ccc4(127,127,127,255) );
this->addChild(m_color);
m_emitter = NULL; m_emitter = NULL;
setTouchEnabled( true ); setTouchEnabled( true );
CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
addChild(label, 100, 1000);
label->setPosition( ccp(s.width/2, s.height-50) );
CCLabelTTF *sub = CCLabelTTF::create(subtitle().c_str(), "Arial", 16); CCMenuItemToggle* item4 = CCMenuItemToggle::createWithCallback( std::bind( &ParticleDemo::toggleCallback, this, std::placeholders::_1),
addChild(sub, 100);
sub->setPosition(ccp(s.width/2, s.height-80));
CCMenuItemImage* item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) );
CCMenuItemImage* item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) );
CCMenuItemImage* item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ParticleDemo::nextCallback) );
CCMenuItemToggle* item4 = CCMenuItemToggle::createWithTarget(this,
menu_selector(ParticleDemo::toggleCallback),
CCMenuItemFont::create( "Free Movement" ), CCMenuItemFont::create( "Free Movement" ),
CCMenuItemFont::create( "Relative Movement" ), CCMenuItemFont::create( "Relative Movement" ),
CCMenuItemFont::create( "Grouped Movement" ), CCMenuItemFont::create( "Grouped Movement" ),
NULL ); NULL );
CCMenu *menu = CCMenu::create(item1, item2, item3, item4, NULL); CCMenu *menu = CCMenu::create(item4, NULL);
menu->setPosition( CCPointZero ); menu->setPosition( CCPointZero );
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item4->setPosition( ccp( VisibleRect::left().x, VisibleRect::bottom().y+ 100) ); item4->setPosition( ccp( VisibleRect::left().x, VisibleRect::bottom().y+ 100) );
item4->setAnchorPoint( ccp(0,0) ); item4->setAnchorPoint( ccp(0,0) );
@ -1123,9 +1108,6 @@ void ParticleDemo::onEnter(void)
scheduleUpdate(); scheduleUpdate();
CCLabelTTF* pLabel = (CCLabelTTF*)(this->getChildByTag(1000));
pLabel->setString(title().c_str());
} }
std::string ParticleDemo::title() std::string ParticleDemo::title()
@ -1229,7 +1211,7 @@ void ParticleBatchHybrid::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1277,7 +1259,7 @@ void ParticleBatchMultipleEmitters::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1320,7 +1302,7 @@ void ParticleReorder::onEnter()
ParticleDemo::onEnter(); ParticleDemo::onEnter();
m_nOrder = 0; m_nOrder = 0;
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1490,7 +1472,7 @@ void Issue1201::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1520,7 +1502,7 @@ void MultipleParticleSystems::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1575,7 +1557,7 @@ void MultipleParticleSystemsBatched::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1637,7 +1619,7 @@ void AddAndDeleteParticleSystems::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background, true); removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1726,7 +1708,7 @@ void ReorderParticleSystems::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
setColor(ccBLACK); m_color->setColor(ccBLACK);
removeChild(m_background ,true); removeChild(m_background ,true);
m_background = NULL; m_background = NULL;
@ -1872,7 +1854,7 @@ void PremultipliedAlphaTest::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
this->setColor(ccBLUE); m_color->setColor(ccBLUE);
this->removeChild(m_background, true); this->removeChild(m_background, true);
m_background = NULL; m_background = NULL;
@ -1904,7 +1886,7 @@ void PremultipliedAlphaTest2::onEnter()
{ {
ParticleDemo::onEnter(); ParticleDemo::onEnter();
this->setColor(ccBLACK); m_color->setColor(ccBLACK);
this->removeChild(m_background, true); this->removeChild(m_background, true);
m_background = NULL; m_background = NULL;

View File

@ -2,6 +2,7 @@
#define _PARTICLE_TEST_H_ #define _PARTICLE_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
////----#include "cocos2d.h" ////----#include "cocos2d.h"
// #include "touch_dispatcher/CCTouch.h" // #include "touch_dispatcher/CCTouch.h"
// #include "CCParticleExample.h" // #include "CCParticleExample.h"
@ -12,11 +13,12 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class ParticleDemo : public CCLayerColor class ParticleDemo : public BaseTest
{ {
protected: protected:
CCParticleSystem* m_emitter; CCParticleSystem* m_emitter;
CCSprite* m_background; CCSprite* m_background;
CCLayerColor* m_color;
public: public:
~ParticleDemo(void); ~ParticleDemo(void);

View File

@ -1 +1 @@
eff4f2aa0226630c0b7749f48604f100212b964e 548013044691d4d3c7d3b2dec546b0aaa90cee8c

View File

@ -3,9 +3,10 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
#include <string> #include <string>
class SpriteTestDemo : public CCLayer class SpriteTestDemo : public BaseTest
{ {
protected: protected:
std::string m_strTitle; std::string m_strTitle;

View File

@ -8,120 +8,60 @@ enum {
kTagSprite2 = 3, kTagSprite2 = 3,
}; };
typedef CCLayer* (*NEWTEXTURE2DTESTFUNC)(); static std::function<CCLayer*()> createFunctions[] =
#define TEXTURE2D_CREATE_FUNC(className) \
static CCLayer* create##className() \
{ return new className(); }
TEXTURE2D_CREATE_FUNC(TextureMemoryAlloc);
TEXTURE2D_CREATE_FUNC(TextureAlias);
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap);
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap2);
TEXTURE2D_CREATE_FUNC(TexturePVRNonSquare);
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT4444);
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT8888);
TEXTURE2D_CREATE_FUNC(TexturePVR);
TEXTURE2D_CREATE_FUNC(TexturePVR2BPP);
TEXTURE2D_CREATE_FUNC(TexturePVR2BPPv3);
TEXTURE2D_CREATE_FUNC(TexturePVR4BPP);
TEXTURE2D_CREATE_FUNC(TexturePVR4BPPv3);
TEXTURE2D_CREATE_FUNC(TexturePVRII4BPPv3);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA8888);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA8888v3);
TEXTURE2D_CREATE_FUNC(TexturePVRBGRA8888);
TEXTURE2D_CREATE_FUNC(TexturePVRBGRA8888v3);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA4444);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA4444v3);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA4444GZ);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA4444CCZ);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA5551);
TEXTURE2D_CREATE_FUNC(TexturePVRRGBA5551v3);
TEXTURE2D_CREATE_FUNC(TexturePVRRGB565);
TEXTURE2D_CREATE_FUNC(TexturePVRRGB565v3);
TEXTURE2D_CREATE_FUNC(TexturePVRRGB888);
TEXTURE2D_CREATE_FUNC(TexturePVRRGB888v3);
TEXTURE2D_CREATE_FUNC(TexturePVRA8);
TEXTURE2D_CREATE_FUNC(TexturePVRA8v3);
TEXTURE2D_CREATE_FUNC(TexturePVRI8);
TEXTURE2D_CREATE_FUNC(TexturePVRI8v3);
TEXTURE2D_CREATE_FUNC(TexturePVRAI88);
TEXTURE2D_CREATE_FUNC(TexturePVRAI88v3);
TEXTURE2D_CREATE_FUNC(TexturePVRv3Premult);
TEXTURE2D_CREATE_FUNC(TexturePVRBadEncoding);
TESTLAYER_CREATE_FUNC(TexturePNG);
TESTLAYER_CREATE_FUNC(TextureJPEG);
TESTLAYER_CREATE_FUNC(TextureTIFF);
TESTLAYER_CREATE_FUNC(TextureWEBP);
TESTLAYER_CREATE_FUNC(TexturePixelFormat);
TESTLAYER_CREATE_FUNC(TextureBlend);
TESTLAYER_CREATE_FUNC(TextureAsync);
TESTLAYER_CREATE_FUNC(TextureGlClamp);
TESTLAYER_CREATE_FUNC(TextureGlRepeat);
TESTLAYER_CREATE_FUNC(TextureSizeTest);
TESTLAYER_CREATE_FUNC(TextureCache1);
TESTLAYER_CREATE_FUNC(TextureDrawAtPoint);
TESTLAYER_CREATE_FUNC(TextureDrawInRect);
TESTLAYER_CREATE_FUNC(TextureETC1);
static NEWTEXTURE2DTESTFUNC createFunctions[] =
{ {
createTextureMemoryAlloc, CL(TextureMemoryAlloc),
createTextureAlias, CL(TextureAlias),
createTexturePVRMipMap, CL(TexturePVRMipMap),
createTexturePVRMipMap2, CL(TexturePVRMipMap2),
createTexturePVRNonSquare, CL(TexturePVRNonSquare),
createTexturePVRNPOT4444, CL(TexturePVRNPOT4444),
createTexturePVRNPOT8888, CL(TexturePVRNPOT8888),
createTexturePVR, CL(TexturePVR),
createTexturePVR2BPP, CL(TexturePVR2BPP),
createTexturePVR2BPPv3, CL(TexturePVR2BPPv3),
createTexturePVR4BPP, CL(TexturePVR4BPP),
createTexturePVR4BPPv3, CL(TexturePVR4BPPv3),
createTexturePVRII4BPPv3, CL(TexturePVRII4BPPv3),
createTexturePVRRGBA8888, CL(TexturePVRRGBA8888),
createTexturePVRRGBA8888v3, CL(TexturePVRRGBA8888v3),
createTexturePVRBGRA8888, CL(TexturePVRBGRA8888),
createTexturePVRBGRA8888v3, CL(TexturePVRBGRA8888v3),
createTexturePVRRGBA4444, CL(TexturePVRRGBA4444),
createTexturePVRRGBA4444v3, CL(TexturePVRRGBA4444v3),
createTexturePVRRGBA4444GZ, CL(TexturePVRRGBA4444GZ),
createTexturePVRRGBA4444CCZ, CL(TexturePVRRGBA4444CCZ),
createTexturePVRRGBA5551, CL(TexturePVRRGBA5551),
createTexturePVRRGBA5551v3, CL(TexturePVRRGBA5551v3),
createTexturePVRRGB565, CL(TexturePVRRGB565),
createTexturePVRRGB565v3, CL(TexturePVRRGB565v3),
createTexturePVRRGB888, CL(TexturePVRRGB888),
createTexturePVRRGB888v3, CL(TexturePVRRGB888v3),
createTexturePVRA8, CL(TexturePVRA8),
createTexturePVRA8v3, CL(TexturePVRA8v3),
createTexturePVRI8, CL(TexturePVRI8),
createTexturePVRI8v3, CL(TexturePVRI8v3),
createTexturePVRAI88, CL(TexturePVRAI88),
createTexturePVRAI88v3, CL(TexturePVRAI88v3),
createTexturePVRv3Premult, CL(TexturePVRv3Premult),
createTexturePVRBadEncoding, CL(TexturePVRBadEncoding),
createTexturePNG, CL(TexturePNG),
createTextureJPEG, CL(TextureJPEG),
createTextureTIFF, CL(TextureTIFF),
createTextureWEBP, CL(TextureWEBP),
createTexturePixelFormat, CL(TexturePixelFormat),
createTextureBlend, CL(TextureBlend),
createTextureAsync, CL(TextureAsync),
createTextureGlClamp, CL(TextureGlClamp),
createTextureGlRepeat, CL(TextureGlRepeat),
createTextureSizeTest, CL(TextureSizeTest),
createTextureCache1, CL(TextureCache1),
createTextureDrawAtPoint, CL(TextureDrawAtPoint),
createTextureDrawInRect, CL(TextureDrawInRect),
createTextureETC1, CL(TextureETC1),
}; };
static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]); static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]);
@ -172,33 +112,10 @@ CCLayer* restartTextureTest()
//------------------------------------------------------------------ //------------------------------------------------------------------
void TextureDemo::onEnter() void TextureDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26);
addChild(label, 1, kTagLabel);
label->setPosition(ccp(s.width/2, s.height-50));
std::string strSubtitle = subtitle();
if(strSubtitle.length())
{
CCLabelTTF *l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width/2, s.height-80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextureDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextureDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextureDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
CCLayerColor *col = CCLayerColor::create(ccc4(128,128,128,255)); CCLayerColor *col = CCLayerColor::create(ccc4(128,128,128,255));
addChild(col, -10); addChild(col, -10);
@ -1393,10 +1310,7 @@ void TexturePixelFormat::onEnter()
// 3- 16-bit RGB5A1 // 3- 16-bit RGB5A1
// 4- 16-bit RGB565 // 4- 16-bit RGB565
TextureDemo::onEnter(); TextureDemo::onEnter();
CCLabelTTF *label = (CCLabelTTF*) getChildByTag(kTagLabel);
label->setColor(ccc3(16,16,255));
CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *background = CCLayerColor::create(ccc4(128,128,128,255), s.width, s.height); CCLayerColor *background = CCLayerColor::create(ccc4(128,128,128,255), s.width, s.height);

View File

@ -2,9 +2,10 @@
#define __TEXTURE2D_TEST_H__ #define __TEXTURE2D_TEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class TextureDemo : public CCLayer class TextureDemo : public BaseTest
{ {
public: public:
virtual ~TextureDemo(); virtual ~TextureDemo();

View File

@ -26,4 +26,8 @@ static CCLayer* create##className() \
#define CF(className) create##className #define CF(className) create##className
// C++ 11
#define CL(__className__) [](){ return new __className__();}
#endif #endif

View File

@ -1 +1 @@
8922f463911cface3b01435714d824c97adf5948 509eda87a0dd525207e23c811e04786bf5b2e3c6

View File

@ -1 +1 @@
bd72399cc616a35a20111d4a5bedc5c473e93e37 04925ef9a72a8d03563f5578810893e794504e6e