Updated CCControlExtension

This commit is contained in:
James Chen 2012-04-16 21:51:06 +08:00
parent 959acd556f
commit ac6e263621
8 changed files with 201 additions and 173 deletions

View File

@ -106,6 +106,8 @@ public:
}; };
#define CCStringMake(str) CCString::stringWithCString(str) #define CCStringMake(str) CCString::stringWithCString(str)
#define ccs CCStringMake
NS_CC_END NS_CC_END

View File

@ -25,47 +25,52 @@
#include "ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h" #include "ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h"
CCControlButtonTest_HelloVariableSize::CCControlButtonTest_HelloVariableSize() bool CCControlButtonTest_HelloVariableSize::init()
{ {
CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
// Defines an array of title to create buttons dynamically // Defines an array of title to create buttons dynamically
CCArray *stringArray = CCArray::arrayWithObjects( CCArray *stringArray = CCArray::arrayWithObjects(
CCStringMake("Hello"), ccs("Hello"),
CCStringMake("Variable"), ccs("Variable"),
CCStringMake("Size"), ccs("Size"),
CCStringMake("!"), ccs("!"),
NULL); NULL);
CCNode *layer = CCNode::node(); CCNode *layer = CCNode::node();
addChild(layer, 1); addChild(layer, 1);
double total_width = 0, height = 0; double total_width = 0, height = 0;
// For each title in the array // For each title in the array
CCObject* pObj = NULL; CCObject* pObj = NULL;
CCARRAY_FOREACH(stringArray, pObj) CCARRAY_FOREACH(stringArray, pObj)
{ {
CCString* title = (CCString*)pObj; CCString* title = (CCString*)pObj;
// Creates a button with this string as title // Creates a button with this string as title
CCControlButton *button = standardButtonWithTitle(title->getCString()); CCControlButton *button = standardButtonWithTitle(title->getCString());
button->setPosition(ccp (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2)); button->setPosition(ccp (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2));
layer->addChild(button); layer->addChild(button);
// Compute the size of the layer // Compute the size of the layer
height = button->getContentSize().height; height = button->getContentSize().height;
total_width += button->getContentSize().width; total_width += button->getContentSize().width;
} }
layer->setAnchorPoint(ccp (0.5, 0.5)); layer->setAnchorPoint(ccp (0.5, 0.5));
layer->setContentSize(CCSizeMake(total_width, height)); layer->setContentSize(CCSizeMake(total_width, height));
layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
// Add the black background // Add the black background
CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("buttonBackground.png"); CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("buttonBackground.png");
background->setContentSize(CCSizeMake(total_width + 14, height + 14)); background->setContentSize(CCSizeMake(total_width + 14, height + 14));
background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(background); addChild(background);
return true;
}
return false;
} }
CCControlButton *CCControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title) CCControlButton *CCControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title)
@ -90,48 +95,52 @@ CCControlButtonTest_Event::~CCControlButtonTest_Event()
CC_SAFE_RELEASE_NULL(m_pDisplayValueLabel); CC_SAFE_RELEASE_NULL(m_pDisplayValueLabel);
} }
CCControlButtonTest_Event::CCControlButtonTest_Event() bool CCControlButtonTest_Event::init()
{ {
CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
// Add a label in which the button events will be displayed // Add a label in which the button events will be displayed
setDisplayValueLabel(CCLabelTTF::labelWithString("No Event", "Marker Felt", 32)); setDisplayValueLabel(CCLabelTTF::labelWithString("No Event", "Marker Felt", 32));
m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1)); m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1));
m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(m_pDisplayValueLabel, 1); addChild(m_pDisplayValueLabel, 1);
// Add the button // Add the button
CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("button.png"); CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("button.png");
CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::spriteWithFile("buttonHighlighted.png"); CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::spriteWithFile("buttonHighlighted.png");
CCLabelTTF *titleButton = CCLabelTTF::labelWithString("Touch Me!", "Marker Felt", 30); CCLabelTTF *titleButton = CCLabelTTF::labelWithString("Touch Me!", "Marker Felt", 30);
titleButton->setColor(ccc3(159, 168, 176)); titleButton->setColor(ccc3(159, 168, 176));
CCControlButton *controlButton = CCControlButton::buttonWithLabelAndBackgroundSprite(titleButton CCControlButton *controlButton = CCControlButton::buttonWithLabelAndBackgroundSprite(titleButton, backgroundButton);
backgroundButton); controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
controlButton->setAnchorPoint(ccp(0.5f, 1)); controlButton->setAnchorPoint(ccp(0.5f, 1));
controlButton->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); controlButton->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(controlButton, 1); addChild(controlButton, 1);
// Add the black background // Add the black background
CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("buttonBackground.png"); CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("buttonBackground.png");
background->setContentSize(CCSizeMake(300, 170)); background->setContentSize(CCSizeMake(300, 170));
background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(background); addChild(background);
// Sets up event handlers // Sets up event handlers
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside);
controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel); controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel);
return true;
}
return false;
} }
void CCControlButtonTest_Event::touchDownAction(CCObject *sender) void CCControlButtonTest_Event::touchDownAction(CCObject *sender)
@ -177,42 +186,47 @@ void CCControlButtonTest_Event::touchCancelAction(CCObject *sender)
//CCControlButtonTest_Styling //CCControlButtonTest_Styling
CCControlButtonTest_Styling::CCControlButtonTest_Styling() bool CCControlButtonTest_Styling::init()
{ {
CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
CCNode *layer = CCNode::node(); CCNode *layer = CCNode::node();
addChild(layer, 1); addChild(layer, 1);
int space = 10; // px int space = 10; // px
double max_w = 0, max_h = 0; double max_w = 0, max_h = 0;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
// Add the buttons // Add the buttons
CCControlButton *button = standardButtonWithTitle(CCString::stringWithFormat("%d",rand() % 30)->getCString()); CCControlButton *button = standardButtonWithTitle(CCString::stringWithFormat("%d",rand() % 30)->getCString());
button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust
// It'll use the prefered size of the background image // It'll use the prefered size of the background image
button->setPosition(ccp (button->getContentSize().width / 2 + (button->getContentSize().width + space) * i, button->setPosition(ccp (button->getContentSize().width / 2 + (button->getContentSize().width + space) * i,
button->getContentSize().height / 2 + (button->getContentSize().height + space) * j); button->getContentSize().height / 2 + (button->getContentSize().height + space) * j));
layer->addChild(button); layer->addChild(button);
max_w = MAX(button->getContentSize().width * (i + 1) + space * i, max_w); max_w = MAX(button->getContentSize().width * (i + 1) + space * i, max_w);
max_h = MAX(button->getContentSize().height * (j + 1) + space * j, max_h); max_h = MAX(button->getContentSize().height * (j + 1) + space * j, max_h);
} }
} }
layer->setAnchorPoint(ccp (0.5, 0.5)); layer->setAnchorPoint(ccp (0.5, 0.5));
layer->setContentSize(CCSizeMake(max_w, max_h)); layer->setContentSize(CCSizeMake(max_w, max_h));
layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
// Add the black background // Add the black background
CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("buttonBackground.png"); CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("buttonBackground.png");
backgroundButton->setContentSize(CCSizeMake(max_w + 14, max_h + 14)); backgroundButton->setContentSize(CCSizeMake(max_w + 14, max_h + 14));
backgroundButton->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); backgroundButton->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
addChild(backgroundButton); addChild(backgroundButton);
return true;
}
return false;
} }

View File

@ -23,22 +23,26 @@
* *
*/ */
#include "ExtensionsTest/ControlExtensionTest/CCControlScene.h" #ifndef __CCCONTROLBUTTONTEST_H__
#define __CCCONTROLBUTTONTEST_H__
#include "../CCControlScene.h"
class CCControlButtonTest_HelloVariableSize : public CCControlScene class CCControlButtonTest_HelloVariableSize : public CCControlScene
{ {
public: public:
CCControlButtonTest_HelloVariableSize(); bool init();
/** Creates and return a button with a default background and title color. */ /** Creates and return a button with a default background and title color. */
CCControlButton *standardButtonWithTitle(const char * title); CCControlButton *standardButtonWithTitle(const char * title);
SCENE_NODE_FUNC(CCControlButtonTest_HelloVariableSize) CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_HelloVariableSize)
}; };
class CCControlButtonTest_Event : public CCControlScene class CCControlButtonTest_Event : public CCControlScene
{ {
public: public:
CCControlButtonTest_Event(); ~CCControlButtonTest_Event();
bool init();
void touchDownAction(CCObject *sender); void touchDownAction(CCObject *sender);
void touchDragInsideAction(CCObject *sender); void touchDragInsideAction(CCObject *sender);
void touchDragOutsideAction(CCObject *sender); void touchDragOutsideAction(CCObject *sender);
@ -50,15 +54,17 @@ public:
protected: protected:
CCLabelTTF *displayEvents; CCLabelTTF *displayEvents;
CC_SYNTHESIZE_RETAIN(CCLabelTTF *, m_pDisplayValueLabel, DisplayValueLabel) CC_SYNTHESIZE_RETAIN(CCLabelTTF *, m_pDisplayValueLabel, DisplayValueLabel)
SCENE_NODE_FUNC(CCControlButtonTest_Event) CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_Event)
}; };
class CCControlButtonTest_Styling : public CCControlScene class CCControlButtonTest_Styling : public CCControlScene
{ {
public: public:
CCControlButtonTest_Styling(); bool init();
CCControlButton *standardButtonWithTitle(const char *title); CCControlButton *standardButtonWithTitle(const char *title);
SCENE_NODE_FUNC(CCControlButtonTest_Styling) CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_Styling)
}; };
#endif /* __CCCONTROLBUTTONTEST_H__ */

View File

@ -47,7 +47,7 @@ bool CCControlScene::init()
CCSize screensize = CCDirector::sharedDirector()->getWinSize(); CCSize screensize = CCDirector::sharedDirector()->getWinSize();
// Add the generated background // Add the generated background
CCSprite *background = CCSprite spriteWithFile("background.png"); CCSprite *background = CCSprite::spriteWithFile("background.png");
background->setPosition(ccp(screensize.width / 2, screensize.height / 2)); background->setPosition(ccp(screensize.width / 2, screensize.height / 2));
addChild(background); addChild(background);
@ -59,19 +59,19 @@ bool CCControlScene::init()
// Add the title // Add the title
setSceneTitleLabel(CCLabelTTF::labelWithString("Title", "Arial", 12)); setSceneTitleLabel(CCLabelTTF::labelWithString("Title", "Arial", 12));
m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5)]; m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
addChild(m_pSceneTitleLabel, 1); addChild(m_pSceneTitleLabel, 1);
// Add the menu // Add the menu
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("b1.png", "b2.png", this, menu_selector(CCControlScene::previousCallback))); CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("b1.png", "b2.png", this, menu_selector(CCControlScene::previousCallback));
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("r1.png", "r2.png", this, menu_selector(CCControlScene::restartCallback))); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("r1.png", "r2.png", this, menu_selector(CCControlScene::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("f1.png", "f2.png", this, menu_selector(CCControlScene::nextCallback))); CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("f1.png", "f2.png", this, menu_selector(CCControlScene::nextCallback));
CCMenu *menu = CCMenu::menuWithItems(item1, item3, item2, NULL); CCMenu *menu = CCMenu::menuWithItems(item1, item3, item2, NULL);
menu->setPosition(CCPointZero); menu->setPosition(CCPointZero);
item1 setPosition(ccp(screensize.width / 2 - 100, 37)); item1->setPosition(ccp(screensize.width / 2 - 100, 37));
item2 setPosition(ccp(screensize.width / 2, 35)); item2->setPosition(ccp(screensize.width / 2, 35));
item3 setPosition(ccp(screensize.width / 2 + 100, 37)); item3->setPosition(ccp(screensize.width / 2 + 100, 37));
addChild(menu ,1); addChild(menu ,1);
return true; return true;
@ -79,18 +79,17 @@ bool CCControlScene::init()
return false; return false;
} }
void CCControlScene::previousCallback(CCNode* sender) void CCControlScene::previousCallback(CCObject* sender)
{ {
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->previousControlScene()); CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->previousControlScene());
} }
void CCControlScene::restartCallback(CCNode* sender) void CCControlScene::restartCallback(CCObject* sender)
{ {
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->currentControlScene()); CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->currentControlScene());
} }
void CCControlScene::nextCallback(CCNode* sender) void CCControlScene::nextCallback(CCObject* sender)
{ {
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->nextControlScene()); CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->nextControlScene());
} }

View File

@ -23,56 +23,49 @@
* *
*/ */
#ifndef __CCCONTROLSCENE_H__
#define __CCCONTROLSCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
// 'scene' is an autorelease object. USING_NS_CC;
// 'layer' is an autorelease object. #define CONTROL_SCENE_NODE_FUNC(controlScene) \
CCControlScene *controlLayer = CCControlScene::node(); public: \
controlLayer->getSceneTitleLabel()->setString(title); static CCScene* sceneWithTitle(const char * title) \
// add layer as a child to scene
scene->addChild(controlLayer);
// return the scene
return scene;
#define CONTROL_SCENE_NODE_FUNC(scene) \
static scene* sceneWithTitle(const char * title) \
{ \ { \
scene *pRet = new scene(); \ CCScene* pScene = CCScene::node(); \
if (pRet && pRet->init()) \ controlScene* controlLayer = new controlScene(); \
{ \ if (controlLayer && controlLayer->init()) \
pRet->autorelease(); \ { \
} \ controlLayer->autorelease(); \
else \ controlLayer->getSceneTitleLabel()->setString(title); \
{ \ pScene->addChild(controlLayer); \
CC_SAFE_DELETE(pRet); \ } \
} \ else \
return pRet; \ { \
CC_SAFE_DELETE(controlLayer); \
} \
return pScene; \
} }
class CCControlScene : public cocos2d::CCLayer class CCControlScene : public cocos2d::CCLayer
{ {
public: public:
CCControlScene();
~CCControlScene(); ~CCControlScene();
bool init(); bool init();
/**
* Returns a CCScene that contains the CCControl example layer.
*
* @param title The title of the scene.
*/
static cocos2d::CCScene* sceneWithTitle(const char * title);
// Menu Callbacks // Menu Callbacks
void previousCallback(cocos2d::CCNode* sender); void previousCallback(cocos2d::CCObject* sender);
void restartCallback(cocos2d::CCNode* sender); void restartCallback(cocos2d::CCObject* sender);
void nextCallback(cocos2d::CCNode* sender); void nextCallback(cocos2d::CCObject* sender);
/** Title label of the scene. */ /** Title label of the scene. */
CC_SYNTHESIZE_RETAIN(cocos2d::CCLabelTTF*, m_pSceneTitleLabel, SceneTitleLabel) CC_SYNTHESIZE_RETAIN(cocos2d::CCLabelTTF*, m_pSceneTitleLabel, SceneTitleLabel)
LAYER_NODE_FUNC(CCControlScene); CONTROL_SCENE_NODE_FUNC(CCControlScene);
}; };
#endif /* __CCCONTROLSCENE_H__ */

View File

@ -25,6 +25,7 @@
#include "CCControlSceneManager.h" #include "CCControlSceneManager.h"
#include "CCControlScene.h" #include "CCControlScene.h"
#include "CCControlButtonTest/CCControlButtonTest.h"
USING_NS_CC; USING_NS_CC;
@ -95,9 +96,9 @@ CCScene *CCControlSceneManager::currentControlScene()
// case kCCControlSliderTest: // case kCCControlSliderTest:
// case kCCControlColourPickerTest: // case kCCControlColourPickerTest:
// case kCCControlSwitchTest: // case kCCControlSwitchTest:
case kCCControlButtonTest_HelloVariableSize:return CCControlButtonTest_HelloVariableSize::node(); case kCCControlButtonTest_HelloVariableSize:return CCControlButtonTest_HelloVariableSize::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]);
case kCCControlButtonTest_Event:return CCControlButtonTest_Event::node(); case kCCControlButtonTest_Event:return CCControlButtonTest_Event::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]);
case kCCControlButtonTest_Styling:return CCControlButtonTest_Styling::node(); case kCCControlButtonTest_Styling:return CCControlButtonTest_Styling::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]);
} }
// return nextControlScene::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]); // return nextControlScene::sceneWithTitle(s_testArray[m_nCurrentControlSceneId]);

View File

@ -22,9 +22,13 @@
* THE SOFTWARE. * THE SOFTWARE.
* *
*/ */
#ifndef __CCCONTROLSCENEMANAGER_H__
#define __CCCONTROLSCENEMANAGER_H__
#include "cocos2d.h" #include "cocos2d.h"
USING_NS_CC;
class CCControlSceneManager : public cocos2d::CCObject class CCControlSceneManager : public cocos2d::CCObject
{ {
public: public:
@ -46,3 +50,4 @@ public:
CC_SYNTHESIZE(int, m_nCurrentControlSceneId, CurrentControlSceneId) CC_SYNTHESIZE(int, m_nCurrentControlSceneId, CurrentControlSceneId)
}; };
#endif /* __CCCONTROLSCENEMANAGER_H__ */

View File

@ -1,18 +1,19 @@
#include "ExtensionsTest.h" #include "ExtensionsTest.h"
#include "../testResource.h" #include "../testResource.h"
#include "NotificationCenterTest.h" #include "NotificationCenterTest/NotificationCenterTest.h"
#include "ControlExtensionTest/CCControlSceneManager.h"
enum enum
{ {
MAX_COUNT = 1, MAX_COUNT = 2,
LINE_SPACE = 40, LINE_SPACE = 40,
kItemTagBasic = 1000, kItemTagBasic = 1000,
}; };
static const std::string testsName[MAX_COUNT] = static const std::string testsName[MAX_COUNT] =
{ {
"NotificationCenterTest" "NotificationCenterTest",
"CCControlButtonTest"
}; };
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
@ -51,6 +52,13 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender)
case 0: case 0:
runNotificationCenterTest(); runNotificationCenterTest();
break; break;
case 1:
{
CCControlSceneManager* pManager = sharedControlSceneManager();
CCScene* pScene = pManager->currentControlScene();
CCDirector::sharedDirector()->replaceScene(pScene);
}
break;
default: default:
break; break;
} }