mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2813 from dumganhar/ricardoquesada-tests_less_warnings
Merge https://github.com/cocos2d/cocos2d-x/pull/2812
This commit is contained in:
commit
1a5de55d39
|
@ -115,23 +115,20 @@ void Box2DTestLayer::initPhysics()
|
|||
|
||||
void Box2DTestLayer::createResetButton()
|
||||
{
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(Box2DTestLayer::reset));
|
||||
|
||||
CCMenu *menu = CCMenu::create(reset, NULL);
|
||||
|
||||
menu->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + 30));
|
||||
this->addChild(menu, -1);
|
||||
|
||||
}
|
||||
|
||||
void Box2DTestLayer::reset(CCObject* sender)
|
||||
{
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", [](CCObject *sender) {
|
||||
CCScene* s = new Box2DTestScene();
|
||||
Box2DTestLayer* child = new Box2DTestLayer();
|
||||
s->addChild(child);
|
||||
child->release();
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
});
|
||||
|
||||
CCMenu *menu = CCMenu::create(reset, NULL);
|
||||
|
||||
menu->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + 30));
|
||||
this->addChild(menu, -1);
|
||||
|
||||
}
|
||||
|
||||
void Box2DTestLayer::draw()
|
||||
|
|
|
@ -28,7 +28,6 @@ public:
|
|||
|
||||
void initPhysics();
|
||||
void createResetButton();
|
||||
void reset(CCObject* sender);
|
||||
virtual void draw();
|
||||
|
||||
void addNewSpriteAtPosition(CCPoint p);
|
||||
|
|
|
@ -67,9 +67,9 @@ bool MenuLayer::initWithEntryID(int entryId)
|
|||
addChild(label, 1);
|
||||
label->setPosition( ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) );
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) );
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &MenuLayer::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", std::bind( &MenuLayer::restartCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &MenuLayer::nextCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ bool Bug1159Layer::init()
|
|||
sprite_b->setPosition(ccp(s.width/2, s.height/2));
|
||||
addChild(sprite_b);
|
||||
|
||||
CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack));
|
||||
CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), std::bind( &Bug1159Layer::callBack, this, std::placeholders::_1) );
|
||||
CCMenu *menu = CCMenu::create(label, NULL);
|
||||
menu->setPosition(ccp(s.width - 200.0f, 50.0f));
|
||||
addChild(menu);
|
||||
|
|
|
@ -31,9 +31,9 @@ void Bug422Layer::reset()
|
|||
removeChild(node, false);
|
||||
// [self removeChildByTag:localtag-1 cleanup:NO];
|
||||
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("One", this, menu_selector(Bug422Layer::menuCallback));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("One", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
|
||||
CCLog("MenuItemFont: %p", item1);
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Two", this, menu_selector(Bug422Layer::menuCallback));
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Two", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
|
||||
CCMenu *menu = CCMenu::create(item1, item2, NULL);
|
||||
menu->alignItemsVertically();
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ bool Bug458Layer::init()
|
|||
// [question setContentSize:CGSizeMake(50,50)];
|
||||
// [question2 setContentSize:CGSizeMake(50,50)];
|
||||
|
||||
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer));
|
||||
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
|
||||
CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100);
|
||||
question->release();
|
||||
question2->release();
|
||||
|
||||
CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100);
|
||||
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer));
|
||||
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
|
||||
CCMenu* menu = CCMenu::create(sprite, sprite2, NULL);
|
||||
menu->alignItemsVerticallyWithPadding(100);
|
||||
menu->setPosition(ccp(size.width / 2, size.height / 2));
|
||||
|
|
|
@ -46,7 +46,7 @@ bool Bug914Layer::init()
|
|||
|
||||
// create and initialize a Label
|
||||
CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64);
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("restart", std::bind( &Bug914Layer::restart, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, NULL);
|
||||
menu->alignItemsVertically();
|
||||
|
|
|
@ -9,38 +9,42 @@
|
|||
#include "Bug-1159.h"
|
||||
#include "Bug-1174.h"
|
||||
|
||||
#define TEST_BUG(bugNO) \
|
||||
#define TEST_BUG(__bug__) \
|
||||
{ \
|
||||
CCScene* pScene = CCScene::create(); \
|
||||
Bug##bugNO##Layer* pLayer = new Bug##bugNO##Layer(); \
|
||||
pLayer->init(); \
|
||||
pScene->addChild(pLayer); \
|
||||
CCDirector::sharedDirector()->replaceScene(pScene); \
|
||||
pLayer->autorelease(); \
|
||||
CCScene* pScene = CCScene::create(); \
|
||||
Bug##__bug__##Layer* pLayer = new Bug##__bug__##Layer(); \
|
||||
pLayer->init(); \
|
||||
pScene->addChild(pLayer); \
|
||||
CCDirector::sharedDirector()->replaceScene(pScene); \
|
||||
pLayer->autorelease(); \
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_COUNT = 9,
|
||||
LINE_SPACE = 40,
|
||||
kItemTagBasic = 5432,
|
||||
};
|
||||
|
||||
static CCPoint s_tCurPos = CCPointZero;
|
||||
|
||||
const std::string testsName[MAX_COUNT] =
|
||||
{
|
||||
"Bug-350",
|
||||
"Bug-422",
|
||||
"Bug-458",
|
||||
"Bug-624",
|
||||
"Bug-886",
|
||||
"Bug-899",
|
||||
"Bug-914",
|
||||
"Bug-1159",
|
||||
"Bug-1174"
|
||||
struct {
|
||||
const char *test_name;
|
||||
std::function<void(CCObject*)> callback;
|
||||
} g_bugs[] = {
|
||||
{ "Bug-350", [](CCObject* sender){ TEST_BUG(350)} },
|
||||
{ "Bug-422", [](CCObject* sender){ TEST_BUG(422)} },
|
||||
{ "Bug-458", [](CCObject* sender){ TEST_BUG(458)} },
|
||||
{ "Bug-624", [](CCObject* sender){ TEST_BUG(624)} },
|
||||
{ "Bug-886", [](CCObject* sender){ TEST_BUG(886)} },
|
||||
{ "Bug-899", [](CCObject* sender){ TEST_BUG(899)} },
|
||||
{ "Bug-914", [](CCObject* sender){ TEST_BUG(914)} },
|
||||
{ "Bug-1159", [](CCObject* sender){ TEST_BUG(1159)} },
|
||||
{ "Bug-1174", [](CCObject* sender){ TEST_BUG(1174)} },
|
||||
};
|
||||
|
||||
static const int g_maxitems = sizeof(g_bugs) / sizeof(g_bugs[0]);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// BugsTestMainLayer
|
||||
|
@ -54,10 +58,9 @@ void BugsTestMainLayer::onEnter()
|
|||
m_pItmeMenu = CCMenu::create();
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < MAX_COUNT; ++i)
|
||||
for (int i = 0; i < g_maxitems; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
||||
menu_selector(BugsTestMainLayer::menuCallback));
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback);
|
||||
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||
m_pItmeMenu->addChild(pItem, kItemTagBasic + i);
|
||||
}
|
||||
|
@ -67,45 +70,6 @@ void BugsTestMainLayer::onEnter()
|
|||
setTouchEnabled(true);
|
||||
}
|
||||
|
||||
void BugsTestMainLayer::menuCallback(CCObject* pSender)
|
||||
{
|
||||
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
||||
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
||||
|
||||
switch (nIndex)
|
||||
{
|
||||
case 0:
|
||||
TEST_BUG(350);
|
||||
break;
|
||||
case 1:
|
||||
TEST_BUG(422);
|
||||
break;
|
||||
case 2:
|
||||
TEST_BUG(458);
|
||||
break;
|
||||
case 3:
|
||||
TEST_BUG(624);
|
||||
break;
|
||||
case 4:
|
||||
TEST_BUG(886);
|
||||
break;
|
||||
case 5:
|
||||
TEST_BUG(899);
|
||||
break;
|
||||
case 6:
|
||||
TEST_BUG(914);
|
||||
break;
|
||||
case 7:
|
||||
TEST_BUG(1159);
|
||||
break;
|
||||
case 8:
|
||||
TEST_BUG(1174);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BugsTestMainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||
{
|
||||
CCSetIterator it = pTouches->begin();
|
||||
|
@ -131,9 +95,9 @@ void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (nextPos.y > ((MAX_COUNT + 1)* LINE_SPACE - winSize.height))
|
||||
if (nextPos.y > ((g_maxitems + 1)* LINE_SPACE - winSize.height))
|
||||
{
|
||||
m_pItmeMenu->setPosition(ccp(0, ((MAX_COUNT + 1)* LINE_SPACE - winSize.height)));
|
||||
m_pItmeMenu->setPosition(ccp(0, ((g_maxitems + 1)* LINE_SPACE - winSize.height)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,8 +117,7 @@ void BugsTestBaseLayer::onEnter()
|
|||
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(BugsTestBaseLayer::backCallback));
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", std::bind( &BugsTestBaseLayer::backCallback, this, std::placeholders::_1));
|
||||
pMainItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pMenu = CCMenu::create(pMainItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
|
|
|
@ -7,7 +7,6 @@ class BugsTestMainLayer : public CCLayer
|
|||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void menuCallback(CCObject* pSender);
|
||||
|
||||
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
|
||||
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
|
||||
|
|
|
@ -50,7 +50,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
|
|||
|
||||
// menu for debug layer
|
||||
CCMenuItemFont::setFontSize(18);
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", this, menu_selector(ChipmunkTestLayer::toggleDebugCallback));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", std::bind( &ChipmunkTestLayer::toggleDebugCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -147,7 +147,7 @@ void ChipmunkTestLayer::update(float delta)
|
|||
|
||||
void ChipmunkTestLayer::createResetButton()
|
||||
{
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(ChipmunkTestLayer::reset));
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &ChipmunkTestLayer::reset, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(reset, NULL);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ m_nSoundId(0)
|
|||
//#else
|
||||
CCLabelTTF* label = CCLabelTTF::create(testItems[i].c_str(), "Arial", 24);
|
||||
//#endif
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(CocosDenshionTest::menuCallback));
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, std::bind( &CocosDenshionTest::menuCallback, this, std::placeholders::_1));
|
||||
|
||||
m_pItmeMenu->addChild(pMenuItem, i + 10000);
|
||||
pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
|
||||
|
|
|
@ -42,8 +42,7 @@ bool CCControlScene::init()
|
|||
{
|
||||
if (CCLayer::init())
|
||||
{
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(CCControlScene::toExtensionsMainLayer));
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &CCControlScene::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
|
||||
pBackMenu->setPosition( CCPointZero );
|
||||
|
@ -66,9 +65,9 @@ bool CCControlScene::init()
|
|||
addChild(m_pSceneTitleLabel, 1);
|
||||
|
||||
// Add the menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &CCControlScene::previousCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &CCControlScene::restartCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &CCControlScene::nextCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
|
|
|
@ -27,7 +27,7 @@ EditBoxTest::EditBoxTest()
|
|||
addChild(m_pTTFShowEditReturn);
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(EditBoxTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &EditBoxTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -22,38 +22,42 @@ enum
|
|||
kItemTagBasic = 1000,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TEST_NOTIFICATIONCENTER = 0,
|
||||
TEST_CCCONTROLBUTTON,
|
||||
TEST_COCOSBUILDER,
|
||||
TEST_HTTPCLIENT,
|
||||
static struct {
|
||||
const char *name;
|
||||
std::function<void(CCObject* sender)> callback;
|
||||
} g_extensionsTests[] = {
|
||||
{ "NotificationCenterTest", [](CCObject* sender) { runNotificationCenterTest(); }
|
||||
},
|
||||
{ "CCControlButtonTest", [](CCObject *sender){
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}},
|
||||
{ "CocosBuilderTest", [](CCObject *sender) {
|
||||
TestScene* pScene = new CocosBuilderTestScene();
|
||||
if (pScene)
|
||||
{
|
||||
pScene->runThisTest();
|
||||
pScene->release();
|
||||
}
|
||||
}},
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
{ "HttpClientTest", [](CCObject *sender){ runHttpClientTest();}
|
||||
},
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
TEST_WEBSOCKET,
|
||||
{ "WebSocketTest", [](CCObject *sender){ runWebSocketTest();}
|
||||
},
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
TEST_EDITBOX,
|
||||
{ "EditBoxTest", [](CCObject *sender){ runEditBoxTest();}
|
||||
},
|
||||
#endif
|
||||
TEST_TABLEVIEW,
|
||||
TEST_MAX_COUNT,
|
||||
{ "TableViewTest", [](CCObject *sender){ runTableViewTest();}
|
||||
},
|
||||
};
|
||||
|
||||
static const std::string testsName[TEST_MAX_COUNT] =
|
||||
{
|
||||
"NotificationCenterTest",
|
||||
"CCControlButtonTest",
|
||||
"CocosBuilderTest",
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
"HttpClientTest",
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
"WebSocketTest",
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
"EditBoxTest",
|
||||
#endif
|
||||
"TableViewTest"
|
||||
};
|
||||
static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]);
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -70,10 +74,9 @@ void ExtensionsMainLayer::onEnter()
|
|||
pMenu->setPosition( CCPointZero );
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < TEST_MAX_COUNT; ++i)
|
||||
for (int i = 0; i < g_maxTests; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
||||
menu_selector(ExtensionsMainLayer::menuCallback));
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback);
|
||||
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||
pMenu->addChild(pItem, kItemTagBasic + i);
|
||||
}
|
||||
|
@ -81,68 +84,6 @@ void ExtensionsMainLayer::onEnter()
|
|||
addChild(pMenu);
|
||||
}
|
||||
|
||||
void ExtensionsMainLayer::menuCallback(CCObject* pSender)
|
||||
{
|
||||
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
||||
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
||||
|
||||
switch (nIndex)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) // MARMALADE CHANGE: Not yet avaiable on Marmalade
|
||||
case TEST_NOTIFICATIONCENTER:
|
||||
{
|
||||
runNotificationCenterTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TEST_CCCONTROLBUTTON:
|
||||
{
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
break;
|
||||
case TEST_COCOSBUILDER:
|
||||
{
|
||||
TestScene* pScene = new CocosBuilderTestScene();
|
||||
if (pScene)
|
||||
{
|
||||
pScene->runThisTest();
|
||||
pScene->release();
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE && CC_TARGET_PLATFORM != CC_PLATFORM_NACL && CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
case TEST_HTTPCLIENT:
|
||||
{
|
||||
runHttpClientTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
case TEST_WEBSOCKET:
|
||||
{
|
||||
runWebSocketTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
case TEST_EDITBOX:
|
||||
{
|
||||
runEditBoxTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TEST_TABLEVIEW:
|
||||
{
|
||||
runTableViewTest();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtensionsTestScene
|
||||
|
|
|
@ -7,7 +7,6 @@ class ExtensionsMainLayer : public CCLayer
|
|||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void menuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class ExtensionsTestScene : public TestScene
|
||||
|
|
|
@ -23,31 +23,31 @@ HttpClientTest::HttpClientTest()
|
|||
|
||||
// Get
|
||||
CCLabelTTF *labelGet = CCLabelTTF::create("Test Get", "Arial", 22);
|
||||
CCMenuItemLabel *itemGet = CCMenuItemLabel::create(labelGet, this, menu_selector(HttpClientTest::onMenuGetTestClicked));
|
||||
CCMenuItemLabel *itemGet = CCMenuItemLabel::create(labelGet, std::bind( &HttpClientTest::onMenuGetTestClicked, this, std::placeholders::_1));
|
||||
itemGet->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - SPACE));
|
||||
menuRequest->addChild(itemGet);
|
||||
|
||||
// Post
|
||||
CCLabelTTF *labelPost = CCLabelTTF::create("Test Post", "Arial", 22);
|
||||
CCMenuItemLabel *itemPost = CCMenuItemLabel::create(labelPost, this, menu_selector(HttpClientTest::onMenuPostTestClicked));
|
||||
CCMenuItemLabel *itemPost = CCMenuItemLabel::create(labelPost, std::bind( &HttpClientTest::onMenuPostTestClicked, this, std::placeholders::_1));
|
||||
itemPost->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemPost);
|
||||
|
||||
// Post Binary
|
||||
CCLabelTTF *labelPostBinary = CCLabelTTF::create("Test Post Binary", "Arial", 22);
|
||||
CCMenuItemLabel *itemPostBinary = CCMenuItemLabel::create(labelPostBinary, this, menu_selector(HttpClientTest::onMenuPostBinaryTestClicked));
|
||||
CCMenuItemLabel *itemPostBinary = CCMenuItemLabel::create(labelPostBinary, std::bind( &HttpClientTest::onMenuPostBinaryTestClicked, this, std::placeholders::_1));
|
||||
itemPostBinary->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemPostBinary);
|
||||
|
||||
// Put
|
||||
CCLabelTTF *labelPut = CCLabelTTF::create("Test Put", "Arial", 22);
|
||||
CCMenuItemLabel *itemPut = CCMenuItemLabel::create(labelPut, this, menu_selector(HttpClientTest::onMenuPutTestClicked));
|
||||
CCMenuItemLabel *itemPut = CCMenuItemLabel::create(labelPut, std::bind( &HttpClientTest::onMenuPutTestClicked, this, std::placeholders::_1));
|
||||
itemPut->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemPut);
|
||||
|
||||
// Delete
|
||||
CCLabelTTF *labelDelete = CCLabelTTF::create("Test Delete", "Arial", 22);
|
||||
CCMenuItemLabel *itemDelete = CCMenuItemLabel::create(labelDelete, this, menu_selector(HttpClientTest::onMenuDeleteTestClicked));
|
||||
CCMenuItemLabel *itemDelete = CCMenuItemLabel::create(labelDelete, std::bind( &HttpClientTest::onMenuDeleteTestClicked, this, std::placeholders::_1));
|
||||
itemDelete->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 5 * SPACE));
|
||||
menuRequest->addChild(itemDelete);
|
||||
|
||||
|
@ -57,7 +57,7 @@ HttpClientTest::HttpClientTest()
|
|||
addChild(m_labelStatusCode);
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(HttpClientTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &HttpClientTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -82,8 +82,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
{
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(NotificationCenterTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &NotificationCenterTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
|
||||
pBackMenu->setPosition( CCPointZero );
|
||||
|
@ -93,7 +92,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("switch on", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind( &NotificationCenterTest::toggleSwitch, this, std::placeholders::_1), item1, item2, NULL);
|
||||
// turn on
|
||||
item->setSelectedIndex(1);
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
|
@ -115,7 +114,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("connected", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind( &NotificationCenterTest::connectToSwitch, this, std::placeholders::_1), item1, item2, NULL);
|
||||
item->setTag(kTagConnect+i);
|
||||
item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
|
||||
menuConnect->addChild(item, 0);
|
||||
|
|
|
@ -39,7 +39,7 @@ bool TableViewTestLayer::init()
|
|||
tableView->reloadData();
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(TableViewTestLayer::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &TableViewTestLayer::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -57,7 +57,12 @@ IntervalLayer::IntervalLayer()
|
|||
addChild(sprite);
|
||||
sprite->runAction( CCRepeatForever::create(CCSequence::create(jump, jump->reverse(), NULL) ));
|
||||
// pause button
|
||||
CCMenuItem* item1 = CCMenuItemFont::create("Pause", this, menu_selector(IntervalLayer::onPause) );
|
||||
CCMenuItem* item1 = CCMenuItemFont::create("Pause", [&](CCObject* sender) {
|
||||
if(CCDirector::sharedDirector()->isPaused())
|
||||
CCDirector::sharedDirector()->resume();
|
||||
else
|
||||
CCDirector::sharedDirector()->pause();
|
||||
});
|
||||
CCMenu* menu = CCMenu::create(item1, NULL);
|
||||
menu->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
|
@ -80,15 +85,6 @@ void IntervalLayer::update(float dt)
|
|||
m_label0->setString(time);
|
||||
}
|
||||
|
||||
void IntervalLayer::onPause(CCObject* pSender)
|
||||
{
|
||||
if(CCDirector::sharedDirector()->isPaused())
|
||||
CCDirector::sharedDirector()->resume();
|
||||
else
|
||||
CCDirector::sharedDirector()->pause();
|
||||
|
||||
}
|
||||
|
||||
void IntervalLayer::step1(float dt)
|
||||
{
|
||||
m_time1 +=dt;
|
||||
|
|
|
@ -18,7 +18,6 @@ public:
|
|||
IntervalLayer(void);
|
||||
virtual ~IntervalLayer();
|
||||
public:
|
||||
void onPause(CCObject* pSender);
|
||||
|
||||
void step1(float dt);
|
||||
void step2(float dt);
|
||||
|
|
|
@ -940,18 +940,18 @@ LabelTTFTest::LabelTTFTest()
|
|||
|
||||
CCMenuItemFont::setFontSize(30);
|
||||
CCMenu *menu = CCMenu::create(
|
||||
CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)),
|
||||
CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)),
|
||||
CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)),
|
||||
CCMenuItemFont::create("Left", std::bind( &LabelTTFTest::setAlignmentLeft, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Center", std::bind( &LabelTTFTest::setAlignmentCenter, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Right", std::bind( &LabelTTFTest::setAlignmentRight, this, std::placeholders::_1)),
|
||||
NULL);
|
||||
menu->alignItemsVerticallyWithPadding(4);
|
||||
menu->setPosition(ccp(50, s.height / 2 - 20));
|
||||
this->addChild(menu);
|
||||
|
||||
menu = CCMenu::create(
|
||||
CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)),
|
||||
CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)),
|
||||
CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)),
|
||||
CCMenuItemFont::create("Top", std::bind( &LabelTTFTest::setAlignmentTop, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Middle", std::bind( &LabelTTFTest::setAlignmentMiddle, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Bottom", std::bind( &LabelTTFTest::setAlignmentBottom, this, std::placeholders::_1)),
|
||||
NULL);
|
||||
menu->alignItemsVerticallyWithPadding(4);
|
||||
menu->setPosition(ccp(s.width - 50, s.height / 2 - 20));
|
||||
|
@ -1155,9 +1155,9 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
|
|||
this->m_pArrowsShouldRetain->retain();
|
||||
|
||||
CCMenuItemFont::setFontSize(20);
|
||||
CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenu *stringMenu = CCMenu::create(longSentences, lineBreaks, mixed, NULL);
|
||||
stringMenu->alignItemsVertically();
|
||||
|
||||
|
@ -1169,9 +1169,9 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
|
|||
|
||||
CCMenuItemFont::setFontSize(30);
|
||||
|
||||
CCMenuItemFont *left = CCMenuItemFont::create("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *center = CCMenuItemFont::create("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *right = CCMenuItemFont::create("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *left = CCMenuItemFont::create("Left", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *center = CCMenuItemFont::create("Center", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *right = CCMenuItemFont::create("Right", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenu *alignmentMenu = CCMenu::create(left, center, right, NULL);
|
||||
alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding);
|
||||
|
||||
|
|
|
@ -6,36 +6,21 @@ enum
|
|||
kTagLayer = 1,
|
||||
};
|
||||
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityA);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityB);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityC);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorA);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorB);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorC);
|
||||
TESTLAYER_CREATE_FUNC(LayerTest1);
|
||||
TESTLAYER_CREATE_FUNC(LayerTest2);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestBlend);
|
||||
TESTLAYER_CREATE_FUNC(LayerGradient);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointPos);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointRot);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointScale);
|
||||
TESTLAYER_CREATE_FUNC(LayerExtendedBlendOpacityTest);
|
||||
|
||||
static NEWTESTFUNC createFunctions[] = {
|
||||
CF(LayerTestCascadingOpacityA),
|
||||
CF(LayerTestCascadingOpacityB),
|
||||
CF(LayerTestCascadingOpacityC),
|
||||
CF(LayerTestCascadingColorA),
|
||||
CF(LayerTestCascadingColorB),
|
||||
CF(LayerTestCascadingColorC),
|
||||
CF(LayerTest1),
|
||||
CF(LayerTest2),
|
||||
CF(LayerTestBlend),
|
||||
CF(LayerGradient),
|
||||
CF(LayerIgnoreAnchorPointPos),
|
||||
CF(LayerIgnoreAnchorPointRot),
|
||||
CF(LayerIgnoreAnchorPointScale),
|
||||
CF(LayerExtendedBlendOpacityTest)
|
||||
static std::function<CCLayer*()> createFunctions[] = {
|
||||
CL(LayerTestCascadingOpacityA),
|
||||
CL(LayerTestCascadingOpacityB),
|
||||
CL(LayerTestCascadingOpacityC),
|
||||
CL(LayerTestCascadingColorA),
|
||||
CL(LayerTestCascadingColorB),
|
||||
CL(LayerTestCascadingColorC),
|
||||
CL(LayerTest1),
|
||||
CL(LayerTest2),
|
||||
CL(LayerTestBlend),
|
||||
CL(LayerGradient),
|
||||
CL(LayerIgnoreAnchorPointPos),
|
||||
CL(LayerIgnoreAnchorPointRot),
|
||||
CL(LayerIgnoreAnchorPointScale),
|
||||
CL(LayerExtendedBlendOpacityTest)
|
||||
};
|
||||
|
||||
static int sceneIdx=-1;
|
||||
|
@ -610,7 +595,7 @@ LayerGradient::LayerGradient()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerGradient::toggleItem), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind(&LayerGradient::toggleItem, this, std::placeholders::_1), item1, item2, NULL);
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
addChild(menu);
|
||||
|
@ -675,7 +660,7 @@ void LayerIgnoreAnchorPointPos::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle ignore anchor point", std::bind( &LayerIgnoreAnchorPointPos::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -723,7 +708,7 @@ void LayerIgnoreAnchorPointRot::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", std::bind( &LayerIgnoreAnchorPointRot::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -774,7 +759,7 @@ void LayerIgnoreAnchorPointScale::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", std::bind( &LayerIgnoreAnchorPointScale::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
|
|
@ -518,9 +518,9 @@ void MenuLayerPriorityTest::menuCallback(CCObject* pSender)
|
|||
// BugsTest
|
||||
BugsTest::BugsTest()
|
||||
{
|
||||
CCMenuItemFont *issue1410 = CCMenuItemFont::create("Issue 1410", this, menu_selector(BugsTest::issue1410MenuCallback));
|
||||
CCMenuItemFont *issue1410_2 = CCMenuItemFont::create("Issue 1410 #2", this, menu_selector(BugsTest::issue1410v2MenuCallback));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("Back", this, menu_selector(BugsTest::backMenuCallback));
|
||||
CCMenuItemFont *issue1410 = CCMenuItemFont::create("Issue 1410", std::bind( &BugsTest::issue1410MenuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemFont *issue1410_2 = CCMenuItemFont::create("Issue 1410 #2", std::bind( &BugsTest::issue1410v2MenuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("Back", std::bind( &BugsTest::backMenuCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(issue1410, issue1410_2, back, NULL);
|
||||
addChild(menu);
|
||||
|
@ -564,7 +564,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
|
|||
item = CCMenuItemFont::create("item 1");
|
||||
item->retain();
|
||||
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("go back", this, menu_selector(RemoveMenuItemWhenMove::goBack));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("go back", std::bind( &RemoveMenuItemWhenMove::goBack, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, back, NULL);
|
||||
addChild(menu);
|
||||
|
|
|
@ -92,9 +92,23 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
quantityOfNodes = nNodes;
|
||||
|
||||
CCMenuItemFont::setFontSize(65);
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease));
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", [&](CCObject *sender) {
|
||||
quantityOfNodes -= kNodesIncrease;
|
||||
if( quantityOfNodes < 0 )
|
||||
quantityOfNodes = 0;
|
||||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
});
|
||||
decrease->setColor(ccc3(0,200,20));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", [&](CCObject *sender) {
|
||||
quantityOfNodes += kNodesIncrease;
|
||||
if( quantityOfNodes > kMaxNodes )
|
||||
quantityOfNodes = kMaxNodes;
|
||||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
});
|
||||
increase->setColor(ccc3(0,200,20));
|
||||
|
||||
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
|
||||
|
@ -115,26 +129,6 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
updateQuantityOfNodes();
|
||||
}
|
||||
|
||||
void NodeChildrenMainScene::onDecrease(CCObject* pSender)
|
||||
{
|
||||
quantityOfNodes -= kNodesIncrease;
|
||||
if( quantityOfNodes < 0 )
|
||||
quantityOfNodes = 0;
|
||||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
}
|
||||
|
||||
void NodeChildrenMainScene::onIncrease(CCObject* pSender)
|
||||
{
|
||||
quantityOfNodes += kNodesIncrease;
|
||||
if( quantityOfNodes > kMaxNodes )
|
||||
quantityOfNodes = kMaxNodes;
|
||||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
}
|
||||
|
||||
std::string NodeChildrenMainScene::title()
|
||||
{
|
||||
return "No title";
|
||||
|
|
|
@ -19,8 +19,6 @@ public:
|
|||
virtual std::string subtitle();
|
||||
virtual void updateQuantityOfNodes() = 0;
|
||||
|
||||
void onDecrease(CCObject* pSender);
|
||||
void onIncrease(CCObject* pSender);
|
||||
void updateQuantityLabel();
|
||||
|
||||
int getQuantityOfNodes() { return quantityOfNodes; }
|
||||
|
|
|
@ -79,9 +79,23 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles)
|
|||
quantityParticles = particles;
|
||||
|
||||
CCMenuItemFont::setFontSize(65);
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease));
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", [&](CCObject *sender) {
|
||||
quantityParticles -= kNodesIncrease;
|
||||
if( quantityParticles < 0 )
|
||||
quantityParticles = 0;
|
||||
|
||||
updateQuantityLabel();
|
||||
createParticleSystem();
|
||||
});
|
||||
decrease->setColor(ccc3(0,200,20));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", [&](CCObject *sender) {
|
||||
quantityParticles += kNodesIncrease;
|
||||
if( quantityParticles > kMaxParticles )
|
||||
quantityParticles = kMaxParticles;
|
||||
|
||||
updateQuantityLabel();
|
||||
createParticleSystem();
|
||||
});
|
||||
increase->setColor(ccc3(0,200,20));
|
||||
|
||||
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
|
||||
|
@ -111,7 +125,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles)
|
|||
{
|
||||
char str[10] = {0};
|
||||
sprintf(str, "%d ", i);
|
||||
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback));
|
||||
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, std::bind( &ParticleMainScene::testNCallback, this, std::placeholders::_1));
|
||||
itemFont->setTag(i);
|
||||
pSubMenu->addChild(itemFont, 10);
|
||||
|
||||
|
@ -249,26 +263,6 @@ void ParticleMainScene::testNCallback(CCObject* pSender)
|
|||
pMenu->restartCallback(pSender);
|
||||
}
|
||||
|
||||
void ParticleMainScene::onIncrease(CCObject* pSender)
|
||||
{
|
||||
quantityParticles += kNodesIncrease;
|
||||
if( quantityParticles > kMaxParticles )
|
||||
quantityParticles = kMaxParticles;
|
||||
|
||||
updateQuantityLabel();
|
||||
createParticleSystem();
|
||||
}
|
||||
|
||||
void ParticleMainScene::onDecrease(CCObject* pSender)
|
||||
{
|
||||
quantityParticles -= kNodesIncrease;
|
||||
if( quantityParticles < 0 )
|
||||
quantityParticles = 0;
|
||||
|
||||
updateQuantityLabel();
|
||||
createParticleSystem();
|
||||
}
|
||||
|
||||
void ParticleMainScene::updateQuantityLabel()
|
||||
{
|
||||
if( quantityParticles != lastRenderedCount )
|
||||
|
|
|
@ -18,8 +18,6 @@ public:
|
|||
|
||||
void step(float dt);
|
||||
void createParticleSystem();
|
||||
void onDecrease(CCObject* pSender);
|
||||
void onIncrease(CCObject* pSender);
|
||||
void testNCallback(CCObject* pSender);
|
||||
void updateQuantityLabel();
|
||||
int getSubTestNum() { return subtestNumber; }
|
||||
|
|
|
@ -287,9 +287,9 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
|
|||
quantityNodes = 0;
|
||||
|
||||
CCMenuItemFont::setFontSize(65);
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(SpriteMainScene::onDecrease));
|
||||
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", std::bind( &SpriteMainScene::onDecrease, this, std::placeholders::_1));
|
||||
decrease->setColor(ccc3(0,200,20));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(SpriteMainScene::onIncrease));
|
||||
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", std::bind( &SpriteMainScene::onIncrease, this, std::placeholders::_1));
|
||||
increase->setColor(ccc3(0,200,20));
|
||||
|
||||
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
|
||||
|
@ -314,7 +314,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
|
|||
{
|
||||
char str[10] = {0};
|
||||
sprintf(str, "%d ", i);
|
||||
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(SpriteMainScene::testNCallback));
|
||||
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, std::bind( &SpriteMainScene::testNCallback, this, std::placeholders::_1));
|
||||
itemFont->setTag(i);
|
||||
pSubMenu->addChild(itemFont, 10);
|
||||
|
||||
|
|
|
@ -8,20 +8,24 @@
|
|||
|
||||
enum
|
||||
{
|
||||
MAX_COUNT = 5,
|
||||
LINE_SPACE = 40,
|
||||
kItemTagBasic = 1000,
|
||||
};
|
||||
|
||||
const std::string testsName[MAX_COUNT] =
|
||||
struct {
|
||||
const char *name;
|
||||
std::function<void(CCObject*)> callback;
|
||||
} g_testsName[] =
|
||||
{
|
||||
"PerformanceNodeChildrenTest",
|
||||
"PerformanceParticleTest",
|
||||
"PerformanceSpriteTest",
|
||||
"PerformanceTextureTest",
|
||||
"PerformanceTouchesTest"
|
||||
{ "PerformanceNodeChildrenTest", [](CCObject*sender){runNodeChildrenTest();} },
|
||||
{ "PerformanceParticleTest",[](CCObject*sender){runParticleTest();} },
|
||||
{ "PerformanceSpriteTest",[](CCObject*sender){runSpriteTest();} },
|
||||
{ "PerformanceTextureTest",[](CCObject*sender){runTextureTest();} },
|
||||
{ "PerformanceTouchesTest",[](CCObject*sender){runTouchesTest();} },
|
||||
};
|
||||
|
||||
static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]);
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// PerformanceMainLayer
|
||||
|
@ -37,10 +41,9 @@ void PerformanceMainLayer::onEnter()
|
|||
pMenu->setPosition( CCPointZero );
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < MAX_COUNT; ++i)
|
||||
for (int i = 0; i < g_testMax; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
||||
menu_selector(PerformanceMainLayer::menuCallback));
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(g_testsName[i].name, g_testsName[i].callback);
|
||||
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||
pMenu->addChild(pItem, kItemTagBasic + i);
|
||||
}
|
||||
|
@ -48,33 +51,6 @@ void PerformanceMainLayer::onEnter()
|
|||
addChild(pMenu);
|
||||
}
|
||||
|
||||
void PerformanceMainLayer::menuCallback(CCObject* pSender)
|
||||
{
|
||||
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
||||
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
||||
|
||||
switch (nIndex)
|
||||
{
|
||||
case 0:
|
||||
runNodeChildrenTest();
|
||||
break;
|
||||
case 1:
|
||||
runParticleTest();
|
||||
break;
|
||||
case 2:
|
||||
runSpriteTest();
|
||||
break;
|
||||
case 3:
|
||||
runTextureTest();
|
||||
break;
|
||||
case 4:
|
||||
runTouchesTest();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// PerformBasicLayer
|
||||
|
@ -94,17 +70,16 @@ void PerformBasicLayer::onEnter()
|
|||
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(PerformBasicLayer::toMainLayer));
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", std::bind( &PerformBasicLayer::toMainLayer, this, std::placeholders::_1));
|
||||
pMainItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pMenu = CCMenu::create(pMainItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
|
||||
if (m_bControlMenuVisible)
|
||||
{
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(PerformBasicLayer::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(PerformBasicLayer::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(PerformBasicLayer::nextCallback) );
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &PerformBasicLayer::backCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &PerformBasicLayer::restartCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &PerformBasicLayer::nextCallback, this, std::placeholders::_1));
|
||||
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));
|
||||
|
|
|
@ -7,7 +7,6 @@ class PerformanceMainLayer : public CCLayer
|
|||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void menuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class PerformBasicLayer : public CCLayer
|
||||
|
|
|
@ -6,21 +6,13 @@
|
|||
// Test #3 by David Deaco (ddeaco)
|
||||
|
||||
|
||||
|
||||
TESTLAYER_CREATE_FUNC(RenderTextureSave);
|
||||
TESTLAYER_CREATE_FUNC(RenderTextureIssue937);
|
||||
TESTLAYER_CREATE_FUNC(RenderTextureZbuffer);
|
||||
TESTLAYER_CREATE_FUNC(RenderTextureTestDepthStencil);
|
||||
TESTLAYER_CREATE_FUNC(RenderTextureTargetNode);
|
||||
TESTLAYER_CREATE_FUNC(SpriteRenderTextureBug);
|
||||
|
||||
static NEWTESTFUNC createFunctions[] = {
|
||||
CF(RenderTextureSave),
|
||||
CF(RenderTextureIssue937),
|
||||
CF(RenderTextureZbuffer),
|
||||
CF(RenderTextureTestDepthStencil),
|
||||
CF(RenderTextureTargetNode),
|
||||
CF(SpriteRenderTextureBug),
|
||||
static std::function<CCLayer*()> createFunctions[] = {
|
||||
CL(RenderTextureSave),
|
||||
CL(RenderTextureIssue937),
|
||||
CL(RenderTextureZbuffer),
|
||||
CL(RenderTextureTestDepthStencil),
|
||||
CL(RenderTextureTargetNode),
|
||||
CL(SpriteRenderTextureBug),
|
||||
};
|
||||
|
||||
#define MAX_LAYER (sizeof(createFunctions)/sizeof(createFunctions[0]))
|
||||
|
@ -60,34 +52,7 @@ static CCLayer* restartTestCase()
|
|||
|
||||
void RenderTextureTest::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 26);
|
||||
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("Images/b1.png", "Images/b2.png", this, menu_selector(RenderTextureTest::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(RenderTextureTest::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(RenderTextureTest::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);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void RenderTextureTest::restartCallback(CCObject* pSender)
|
||||
|
@ -150,8 +115,8 @@ RenderTextureSave::RenderTextureSave()
|
|||
|
||||
// Save Image menu
|
||||
CCMenuItemFont::setFontSize(16);
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("Save Image", this, menu_selector(RenderTextureSave::saveImage));
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Clear", this, menu_selector(RenderTextureSave::clearImage));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("Save Image", std::bind( &RenderTextureSave::saveImage, this, std::placeholders::_1));
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Clear", std::bind( &RenderTextureSave::clearImage, this, std::placeholders::_1));
|
||||
CCMenu *menu = CCMenu::create(item1, item2, NULL);
|
||||
this->addChild(menu);
|
||||
menu->alignItemsVertically();
|
||||
|
@ -564,7 +529,7 @@ RenderTextureTargetNode::RenderTextureTargetNode()
|
|||
scheduleUpdate();
|
||||
|
||||
// Toggle clear on / off
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Clear On/Off", this, menu_selector(RenderTextureTargetNode::touched));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Clear On/Off", std::bind( &RenderTextureTargetNode::touched, this, std::placeholders::_1));
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
addChild(menu);
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class RenderTextureTest : public CCLayer
|
||||
class RenderTextureTest : public BaseTest
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
|
|
|
@ -18,9 +18,9 @@ enum
|
|||
|
||||
SceneTestLayer1::SceneTestLayer1()
|
||||
{
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::create( "Test pushScene", this, menu_selector(SceneTestLayer1::onPushScene) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create( "Test pushScene w/transition", this, menu_selector(SceneTestLayer1::onPushSceneTran) );
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::create( "Quit", this, menu_selector(SceneTestLayer1::onQuit) );
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::create( "Test pushScene", std::bind(&SceneTestLayer1::onPushScene, this, std::placeholders::_1));
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create( "Test pushScene w/transition", std::bind(&SceneTestLayer1::onPushSceneTran, this, std::placeholders::_1));
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::create( "Quit", std::bind(&SceneTestLayer1::onQuit, this, std::placeholders::_1));
|
||||
|
||||
CCMenu* menu = CCMenu::create( item1, item2, item3, NULL );
|
||||
menu->alignItemsVertically();
|
||||
|
@ -103,9 +103,9 @@ SceneTestLayer2::SceneTestLayer2()
|
|||
{
|
||||
m_timeCounter = 0;
|
||||
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::create( "replaceScene", this, menu_selector(SceneTestLayer2::onReplaceScene) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create( "replaceScene w/transition", this, menu_selector(SceneTestLayer2::onReplaceSceneTran) );
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::create( "Go Back", this, menu_selector(SceneTestLayer2::onGoBack) );
|
||||
CCMenuItemFont* item1 = CCMenuItemFont::create( "replaceScene", std::bind(&SceneTestLayer2::onReplaceScene, this, std::placeholders::_1));
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create( "replaceScene w/transition", std::bind(&SceneTestLayer2::onReplaceSceneTran, this, std::placeholders::_1));
|
||||
CCMenuItemFont* item3 = CCMenuItemFont::create( "Go Back", std::bind(&SceneTestLayer2::onGoBack, this, std::placeholders::_1));
|
||||
|
||||
CCMenu* menu = CCMenu::create( item1, item2, item3, NULL );
|
||||
menu->alignItemsVertically();
|
||||
|
@ -171,10 +171,10 @@ bool SceneTestLayer3::init()
|
|||
{
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCMenuItemFont *item0 = CCMenuItemFont::create("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked));
|
||||
CCMenuItemFont *item1 = CCMenuItemFont::create("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked));
|
||||
CCMenuItemFont *item2 = CCMenuItemFont::create("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked));
|
||||
CCMenuItemFont *item3 = CCMenuItemFont::create("Touch to popToSceneStackLevel(2)", this, menu_selector(SceneTestLayer3::item3Clicked));
|
||||
CCMenuItemFont *item0 = CCMenuItemFont::create("Touch to pushScene (self)", std::bind(&SceneTestLayer3::item0Clicked, this, std::placeholders::_1));
|
||||
CCMenuItemFont *item1 = CCMenuItemFont::create("Touch to popScene", std::bind(&SceneTestLayer3::item1Clicked, this, std::placeholders::_1));
|
||||
CCMenuItemFont *item2 = CCMenuItemFont::create("Touch to popToRootScene", std::bind(&SceneTestLayer3::item2Clicked, this, std::placeholders::_1));
|
||||
CCMenuItemFont *item3 = CCMenuItemFont::create("Touch to popToSceneStackLevel(2)", std::bind(&SceneTestLayer3::item3Clicked, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item0, item1, item2, item3, NULL);
|
||||
this->addChild(menu);
|
||||
|
|
|
@ -62,39 +62,6 @@ ShaderTestDemo::ShaderTestDemo()
|
|||
|
||||
}
|
||||
|
||||
bool ShaderTestDemo::init()
|
||||
{
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26);
|
||||
addChild(label, 1);
|
||||
label->setPosition(ccp(s.width/2, s.height-50));
|
||||
label->setColor(ccRED);
|
||||
|
||||
std::string subtitle = this->subtitle();
|
||||
if (subtitle.length() > 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(ShaderTestDemo::backCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ShaderTestDemo::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ShaderTestDemo::nextCallback));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(ccp(0, 0));
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ShaderTestDemo::backCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* s = new ShaderTestScene();
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
|
||||
#include "../testBasic.h"
|
||||
#include "cocos-ext.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
USING_NS_CC_EXT;
|
||||
|
||||
class ShaderTestDemo : public CCLayer
|
||||
class ShaderTestDemo : public BaseTest
|
||||
{
|
||||
public:
|
||||
ShaderTestDemo(void);
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual bool init();
|
||||
|
||||
void restartCallback(CCObject* pSender);
|
||||
void nextCallback(CCObject* pSender);
|
||||
|
|
|
@ -1814,19 +1814,19 @@ void TextureMemoryAlloc::onEnter()
|
|||
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("PNG", this, menu_selector(TextureMemoryAlloc::updateImage));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("PNG", std::bind(&TextureMemoryAlloc::updateImage, this, std::placeholders::_1));
|
||||
item1->setTag(0);
|
||||
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("RGBA8", this, menu_selector(TextureMemoryAlloc::updateImage));
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("RGBA8", std::bind(&TextureMemoryAlloc::updateImage, this, std::placeholders::_1));
|
||||
item2->setTag(1);
|
||||
|
||||
CCMenuItem *item3 = CCMenuItemFont::create("RGB8", this, menu_selector(TextureMemoryAlloc::updateImage));
|
||||
CCMenuItem *item3 = CCMenuItemFont::create("RGB8", std::bind(&TextureMemoryAlloc::updateImage, this, std::placeholders::_1));
|
||||
item3->setTag(2);
|
||||
|
||||
CCMenuItem *item4 = CCMenuItemFont::create("RGBA4", this, menu_selector(TextureMemoryAlloc::updateImage));
|
||||
CCMenuItem *item4 = CCMenuItemFont::create("RGBA4", std::bind(&TextureMemoryAlloc::updateImage, this, std::placeholders::_1));
|
||||
item4->setTag(3);
|
||||
|
||||
CCMenuItem *item5 = CCMenuItemFont::create("A8", this, menu_selector(TextureMemoryAlloc::updateImage));
|
||||
CCMenuItem *item5 = CCMenuItemFont::create("A8", std::bind(&TextureMemoryAlloc::updateImage, this, std::placeholders::_1));
|
||||
item5->setTag(4);
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, item4, item5, NULL);
|
||||
|
@ -1834,7 +1834,7 @@ void TextureMemoryAlloc::onEnter()
|
|||
|
||||
addChild(menu);
|
||||
|
||||
CCMenuItemFont *warmup = CCMenuItemFont::create("warm up texture", this, menu_selector(TextureMemoryAlloc::changeBackgroundVisible));
|
||||
CCMenuItemFont *warmup = CCMenuItemFont::create("warm up texture", std::bind(&TextureMemoryAlloc::changeBackgroundVisible, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu2 = CCMenu::create(warmup, NULL);
|
||||
|
||||
|
|
|
@ -1428,45 +1428,13 @@ CCLayer* restartTileMapAction()
|
|||
|
||||
|
||||
TileDemo::TileDemo(void)
|
||||
: BaseTest()
|
||||
{
|
||||
setTouchEnabled( true );
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
m_label = CCLabelTTF::create("", "Arial", 28);
|
||||
addChild(m_label, 1);
|
||||
m_label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
m_label->retain();
|
||||
|
||||
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) );
|
||||
|
||||
m_subtitle = l;
|
||||
m_subtitle->retain();
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TileDemo::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TileDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TileDemo::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);
|
||||
}
|
||||
|
||||
TileDemo::~TileDemo(void)
|
||||
{
|
||||
m_label->release();
|
||||
m_subtitle->release();
|
||||
}
|
||||
|
||||
std::string TileDemo::title()
|
||||
|
@ -1481,10 +1449,7 @@ std::string TileDemo::subtitle()
|
|||
|
||||
void TileDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
m_label->setString(title().c_str());
|
||||
m_subtitle->setString(subtitle().c_str());
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void TileDemo::restartCallback(CCObject* pSender)
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
#define _TILEMAP_TEST_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class TileDemo : public CCLayer
|
||||
class TileDemo : public BaseTest
|
||||
{
|
||||
protected:
|
||||
CCLabelTTF* m_label;
|
||||
CCLabelTTF* m_subtitle;
|
||||
|
||||
public:
|
||||
TileDemo(void);
|
||||
virtual ~TileDemo(void);
|
||||
|
|
|
@ -30,11 +30,6 @@ PongScene::PongScene()
|
|||
pongLayer->release();
|
||||
}
|
||||
|
||||
void PongScene::MainMenuCallback(CCObject* pSender)
|
||||
{
|
||||
TestScene::MainMenuCallback(pSender);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// PongLayer
|
||||
|
|
|
@ -12,8 +12,6 @@ public:
|
|||
PongScene();
|
||||
|
||||
virtual void runThisTest();
|
||||
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class Ball;
|
||||
|
|
|
@ -89,7 +89,7 @@ TestController::TestController()
|
|||
: m_tBeginPos(CCPointZero)
|
||||
{
|
||||
// add close menu
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, std::bind( &TestController::closeCallback, this, std::placeholders::_1) );
|
||||
CCMenu* pMenu =CCMenu::create(pCloseItem, NULL);
|
||||
|
||||
pMenu->setPosition( CCPointZero );
|
||||
|
|
|
@ -17,7 +17,35 @@ void TestScene::onEnter()
|
|||
//#else
|
||||
CCLabelTTF* label = CCLabelTTF::create("MainMenu", "Arial", 20);
|
||||
//#endif
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestScene::MainMenuCallback));
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, [](CCObject *sender) {
|
||||
/*
|
||||
****** GCC Compiler issue on Android and Linux (CLANG compiler is ok) ******
|
||||
We couldn't use 'CCScene::create' directly since gcc will trigger
|
||||
an error called "error: 'this' was not captured for this lambda function".
|
||||
This is because 'CCScene' is the super class of TestScene, if we invoke 'CCScene::create'
|
||||
directly in this lambda expression, gcc compiler found 'CCScene::create' and it think
|
||||
that was the member function of 'TestScene' 's super class, but this lambda function doesn't
|
||||
capture anything like 'this', so it has no access to invoke 'CCScene::create'.
|
||||
|
||||
Solution (1): Passing 'this' to this lambda function.
|
||||
Solution (2): Don't use 'CCScene::create' and don't pass 'this' to this lambda function,
|
||||
instead, we just need to new the 'CCScene' and initialize the Scene.
|
||||
|
||||
Semantically, I think in this lambda function, we shouldn't capture any varibles
|
||||
outside the scope. So I choose the (2) solution. Commented by James Chen.
|
||||
*/
|
||||
|
||||
// CCScene *pScene = CCScene::create();
|
||||
CCScene *pScene = new CCScene();
|
||||
if (pScene && pScene->init())
|
||||
{
|
||||
CCLayer* pLayer = new TestController();
|
||||
pScene->addChild(pLayer);
|
||||
pLayer->release();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
pScene->release();
|
||||
}
|
||||
});
|
||||
|
||||
CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);
|
||||
|
||||
|
@ -26,13 +54,3 @@ void TestScene::onEnter()
|
|||
|
||||
addChild(pMenu, 1);
|
||||
}
|
||||
|
||||
void TestScene::MainMenuCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* pScene = CCScene::create();
|
||||
CCLayer* pLayer = new TestController();
|
||||
pLayer->autorelease();
|
||||
|
||||
pScene->addChild(pLayer);
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,6 @@ public:
|
|||
virtual void onEnter();
|
||||
|
||||
virtual void runThisTest() = 0;
|
||||
|
||||
// The CallBack for back to the main menu scene
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
typedef CCLayer* (*NEWTESTFUNC)();
|
||||
|
|
Loading…
Reference in New Issue