From 0674948325f4338c65e0d8fa4b92235da65b04c2 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 18 Sep 2013 19:38:21 -0700 Subject: [PATCH] Small fixes to comply with C++ best practices Small fixes to comply with C++ best practices --- samples/Cpp/TestCpp/Classes/AppDelegate.cpp | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 2 +- .../CocoStudioGUITest/CocosGUIScene.cpp | 30 ++++++++++--------- .../CocoStudioGUITest/CocosGUIScene.h | 10 +++---- .../CocoStudioSceneTest/SceneEditorTest.cpp | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 398c90744c..2dcd3d1558 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -15,7 +15,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { // SimpleAudioEngine::end(); - cocos2d::extension::armature::ArmatureDataManager::purge(); + cocos2d::extension::armature::ArmatureDataManager::destoryInstance(); } bool AppDelegate::applicationDidFinishLaunching() diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index e5a62d7bac..e93498a3e4 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -122,7 +122,7 @@ void ArmatureTestScene::MainMenuCallback(Object *pSender) //TestScene::MainMenuCallback(pSender); removeAllChildren(); - ArmatureDataManager::purge(); + ArmatureDataManager::destoryInstance(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp index a0f5cd550a..381a093ff9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp @@ -10,7 +10,7 @@ const char* gui_scene_names[2] = }; CocosGUITestScene::CocosGUITestScene(bool bPortrait) -: m_pLabel(NULL) +: _label(NULL) { TestScene::init(); } @@ -39,19 +39,20 @@ void CocosGUITestScene::runThisTest() // /* Size s = CCDirector::getInstance()->getWinSize(); - m_pItemMenu = CCMenu::create(); - m_pItemMenu->setPosition(Point::ZERO); + _itemMenu = CCMenu::create(); + _itemMenu->setPosition(Point::ZERO); MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); for (int i = 0; i < 1; ++i) { - MenuItemFont* pItem = MenuItemFont::create(gui_scene_names[i], this, - menu_selector(CocosGUITestScene::menuCallback)); - pItem->setPosition(Point(s.width / 2, s.height - s.height / 4 - (i + 1) * 40)); - pItem->setTag(i); - m_pItemMenu->addChild(pItem); + auto item = MenuItemFont::create( + gui_scene_names[i], + CC_CALLBACK_1( CocosGUITestScene::menuCallback, this)); + item->setPosition(Point(s.width / 2, s.height - s.height / 4 - (i + 1) * 40)); + item->setTag(i); + _itemMenu->addChild(item); } - addChild(m_pItemMenu); + addChild(_itemMenu); // */ } void CocosGUITestScene::MainMenuCallback(Object* pSender) @@ -62,11 +63,12 @@ void CocosGUITestScene::MainMenuCallback(Object* pSender) pScene->release(); } -void CocosGUITestScene::toCocosGUIExampleScene(Object* pSender) +void CocosGUITestScene::toCocosGUIExampleScene(Object* sender) { - ((UIScrollView*)pSender)->setDirection(SCROLLVIEW_DIR_HORIZONTAL); - ((UIScrollView*)pSender)->getChildByName("backtotopbutton")->setBright(false); - ((UIScrollView*)pSender)->getChildByName("backtotopbutton")->setTouchEnabled(false); + auto scrollView = static_cast(sender); + scrollView->setDirection(SCROLLVIEW_DIR_HORIZONTAL); + scrollView->getChildByName("backtotopbutton")->setBright(false); + scrollView->getChildByName("backtotopbutton")->setTouchEnabled(false); CCLOG("p2 click"); ul->removeFromParent(); @@ -76,7 +78,7 @@ void CocosGUITestScene::load(Object *pSender, int count) { char tmp[10]; sprintf(tmp,"%d", count); - m_pLabel->setString(CCString::createWithFormat("%i", count)->getCString()); + _label->setString(CCString::createWithFormat("%i", count)->getCString()); } void CocosGUITestScene::menuCallback(Object *pSender) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h index 37704fabb4..e1f589eac8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.h @@ -35,14 +35,14 @@ using namespace cocos2d::extension; class CocosGUITestScene : public TestScene { public: - CocosGUITestScene(bool bPortrait = false); + CocosGUITestScene(bool portrait = false); virtual ~CocosGUITestScene(); virtual void runThisTest(); // 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 loadTextureCallBack(Object *obj); @@ -51,9 +51,9 @@ public: UILayer* ul; - LabelTTF* m_pLabel; + LabelTTF* _label; - Menu* m_pItemMenu; + Menu* _itemMenu; }; #endif /* defined(__TestCpp__CocosGUIScene__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 55083983af..b98783cc22 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -8,7 +8,7 @@ using namespace cocos2d::extension; SceneEditorTestLayer::~SceneEditorTestLayer() { - armature::ArmatureDataManager::getInstance()->purge(); + armature::ArmatureDataManager::getInstance()->destoryInstance(); SceneReader::getInstance()->purgeSceneReader(); cocos2d::extension::ActionManagerEx::shareManager()->purgeActionManager(); cocos2d::extension::UIHelper::instance()->purgeUIHelper();