Small fixes to comply with C++ best practices

Small fixes to comply with C++ best practices
This commit is contained in:
Ricardo Quesada 2013-09-18 19:38:21 -07:00
parent 5570b6089a
commit 0674948325
5 changed files with 24 additions and 22 deletions

View File

@ -15,7 +15,7 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate() AppDelegate::~AppDelegate()
{ {
// SimpleAudioEngine::end(); // SimpleAudioEngine::end();
cocos2d::extension::armature::ArmatureDataManager::purge(); cocos2d::extension::armature::ArmatureDataManager::destoryInstance();
} }
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()

View File

@ -122,7 +122,7 @@ void ArmatureTestScene::MainMenuCallback(Object *pSender)
//TestScene::MainMenuCallback(pSender); //TestScene::MainMenuCallback(pSender);
removeAllChildren(); removeAllChildren();
ArmatureDataManager::purge(); ArmatureDataManager::destoryInstance();
} }

View File

@ -10,7 +10,7 @@ const char* gui_scene_names[2] =
}; };
CocosGUITestScene::CocosGUITestScene(bool bPortrait) CocosGUITestScene::CocosGUITestScene(bool bPortrait)
: m_pLabel(NULL) : _label(NULL)
{ {
TestScene::init(); TestScene::init();
} }
@ -39,19 +39,20 @@ void CocosGUITestScene::runThisTest()
// /* // /*
Size s = CCDirector::getInstance()->getWinSize(); Size s = CCDirector::getInstance()->getWinSize();
m_pItemMenu = CCMenu::create(); _itemMenu = CCMenu::create();
m_pItemMenu->setPosition(Point::ZERO); _itemMenu->setPosition(Point::ZERO);
MenuItemFont::setFontName("Arial"); MenuItemFont::setFontName("Arial");
MenuItemFont::setFontSize(24); MenuItemFont::setFontSize(24);
for (int i = 0; i < 1; ++i) for (int i = 0; i < 1; ++i)
{ {
MenuItemFont* pItem = MenuItemFont::create(gui_scene_names[i], this, auto item = MenuItemFont::create(
menu_selector(CocosGUITestScene::menuCallback)); gui_scene_names[i],
pItem->setPosition(Point(s.width / 2, s.height - s.height / 4 - (i + 1) * 40)); CC_CALLBACK_1( CocosGUITestScene::menuCallback, this));
pItem->setTag(i); item->setPosition(Point(s.width / 2, s.height - s.height / 4 - (i + 1) * 40));
m_pItemMenu->addChild(pItem); item->setTag(i);
_itemMenu->addChild(item);
} }
addChild(m_pItemMenu); addChild(_itemMenu);
// */ // */
} }
void CocosGUITestScene::MainMenuCallback(Object* pSender) void CocosGUITestScene::MainMenuCallback(Object* pSender)
@ -62,11 +63,12 @@ void CocosGUITestScene::MainMenuCallback(Object* pSender)
pScene->release(); pScene->release();
} }
void CocosGUITestScene::toCocosGUIExampleScene(Object* pSender) void CocosGUITestScene::toCocosGUIExampleScene(Object* sender)
{ {
((UIScrollView*)pSender)->setDirection(SCROLLVIEW_DIR_HORIZONTAL); auto scrollView = static_cast<UIScrollView*>(sender);
((UIScrollView*)pSender)->getChildByName("backtotopbutton")->setBright(false); scrollView->setDirection(SCROLLVIEW_DIR_HORIZONTAL);
((UIScrollView*)pSender)->getChildByName("backtotopbutton")->setTouchEnabled(false); scrollView->getChildByName("backtotopbutton")->setBright(false);
scrollView->getChildByName("backtotopbutton")->setTouchEnabled(false);
CCLOG("p2 click"); CCLOG("p2 click");
ul->removeFromParent(); ul->removeFromParent();
@ -76,7 +78,7 @@ void CocosGUITestScene::load(Object *pSender, int count)
{ {
char tmp[10]; char tmp[10];
sprintf(tmp,"%d", count); sprintf(tmp,"%d", count);
m_pLabel->setString(CCString::createWithFormat("%i", count)->getCString()); _label->setString(CCString::createWithFormat("%i", count)->getCString());
} }
void CocosGUITestScene::menuCallback(Object *pSender) void CocosGUITestScene::menuCallback(Object *pSender)

View File

@ -35,14 +35,14 @@ using namespace cocos2d::extension;
class CocosGUITestScene : public TestScene class CocosGUITestScene : public TestScene
{ {
public: public:
CocosGUITestScene(bool bPortrait = false); CocosGUITestScene(bool portrait = false);
virtual ~CocosGUITestScene(); virtual ~CocosGUITestScene();
virtual void runThisTest(); virtual void runThisTest();
// The CallBack for back to the main menu scene // The CallBack for back to the main menu scene
virtual void MainMenuCallback(Object* pSender); virtual void MainMenuCallback(Object* sender);
void toCocosGUIExampleScene(Object* pSender); void toCocosGUIExampleScene(Object* sender);
void load(Object* pSender, int count); void load(Object* pSender, int count);
void loadTextureCallBack(Object *obj); void loadTextureCallBack(Object *obj);
@ -51,9 +51,9 @@ public:
UILayer* ul; UILayer* ul;
LabelTTF* m_pLabel; LabelTTF* _label;
Menu* m_pItemMenu; Menu* _itemMenu;
}; };
#endif /* defined(__TestCpp__CocosGUIScene__) */ #endif /* defined(__TestCpp__CocosGUIScene__) */

View File

@ -8,7 +8,7 @@ using namespace cocos2d::extension;
SceneEditorTestLayer::~SceneEditorTestLayer() SceneEditorTestLayer::~SceneEditorTestLayer()
{ {
armature::ArmatureDataManager::getInstance()->purge(); armature::ArmatureDataManager::getInstance()->destoryInstance();
SceneReader::getInstance()->purgeSceneReader(); SceneReader::getInstance()->purgeSceneReader();
cocos2d::extension::ActionManagerEx::shareManager()->purgeActionManager(); cocos2d::extension::ActionManagerEx::shareManager()->purgeActionManager();
cocos2d::extension::UIHelper::instance()->purgeUIHelper(); cocos2d::extension::UIHelper::instance()->purgeUIHelper();