From 9944a5d18634600fa422c7c906ad0bf87c189ce0 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 24 Jul 2013 15:31:20 +0800 Subject: [PATCH] Rename the singleton methods name in sample project of plugin. Remove the deprecated methods. --- .../Classes/TestAds/TestAdsScene.cpp | 20 +++++++++---------- .../TestAnalytics/TestAnalyticsScene.cpp | 10 +++++----- .../Classes/TestIAP/MyPurchase.cpp | 2 +- .../HelloPlugins/Classes/TestIAP/MyPurchase.h | 2 +- .../Classes/TestIAP/TestIAPScene.cpp | 18 ++++++++--------- .../Classes/TestIAPOnline/MyIAPOLManager.cpp | 2 +- .../Classes/TestIAPOnline/MyIAPOLManager.h | 2 +- .../TestIAPOnline/TestIAPOnlineScene.cpp | 4 ++-- .../Classes/TestShare/MyShareManager.cpp | 2 +- .../Classes/TestShare/MyShareManager.h | 2 +- .../Classes/TestShare/TestShareScene.cpp | 4 ++-- .../Classes/TestSocial/MySocialManager.cpp | 2 +- .../Classes/TestSocial/MySocialManager.h | 2 +- .../Classes/TestSocial/TestSocialScene.cpp | 10 +++++----- .../Classes/TestUser/MyUserManager.cpp | 2 +- .../Classes/TestUser/MyUserManager.h | 2 +- .../Classes/TestUser/TestUserScene.cpp | 6 +++--- 17 files changed, 46 insertions(+), 46 deletions(-) diff --git a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp index 40a85b0ffe..0ebfaa5840 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp @@ -89,8 +89,8 @@ bool TestAds::init() Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); - Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); - Point posBR = ccp(origin.x + visibleSize.width, origin.y); + Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); + Point posBR = Point(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -99,7 +99,7 @@ bool TestAds::init() // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); @@ -107,15 +107,15 @@ bool TestAds::init() LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24); MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this)); - pItemShow->setAnchorPoint(ccp(0.5f, 0)); + pItemShow->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(pItemShow, 0); - pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120))); + pItemShow->setPosition(posMid + Point(-100, -120)); LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24); MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this)); - pItemHide->setAnchorPoint(ccp(0.5f, 0)); + pItemHide->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(pItemHide, 0); - pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120))); + pItemHide->setPosition(posMid + Point(100, -120)); // create optional menu // cases item @@ -127,7 +127,7 @@ bool TestAds::init() { _caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) ); } - _caseItem->setPosition(ccpAdd(posMid, ccp(-200, 120))); + _caseItem->setPosition(posMid + Point(-200, 120)); pMenu->addChild(_caseItem); // type item @@ -139,7 +139,7 @@ bool TestAds::init() { _typeItem->getSubItems()->addObject( MenuItemFont::create( s_aTestTypes[i].c_str() ) ); } - _typeItem->setPosition(ccpAdd(posMid, ccp(0, 120))); + _typeItem->setPosition(posMid + Point(0, 120)); pMenu->addChild(_typeItem); // poses item @@ -151,7 +151,7 @@ bool TestAds::init() { _posItem->getSubItems()->addObject( MenuItemFont::create( s_aTestPoses[i].c_str() ) ); } - _posItem->setPosition(ccpAdd(posMid, ccp(200, 120))); + _posItem->setPosition(posMid + Point(200, 120)); pMenu->addChild(_posItem); // init options diff --git a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp index b24d7b409f..a5e20d1584 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp @@ -89,7 +89,7 @@ bool TestAnalytics::init() Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); - Point posBR = ccp(origin.x + visibleSize.width, origin.y); + Point posBR = Point(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -98,7 +98,7 @@ bool TestAnalytics::init() // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); @@ -111,15 +111,15 @@ bool TestAnalytics::init() MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); yPos = visibleSize.height - 35*i - 100; - pMenuItem->setPosition( ccp(visibleSize.width / 2, yPos)); + pMenuItem->setPosition( Point(visibleSize.width / 2, yPos)); } std::string strName = _pluginAnalytics->getPluginName(); std::string strVer = _pluginAnalytics->getSDKVersion(); char ret[256] = { 0 }; sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); - LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(visibleSize.width, 0), kTextAlignmentCenter); - pLabel->setPosition(ccp(visibleSize.width / 2, yPos - 80)); + LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), kTextAlignmentCenter); + pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80)); addChild(pLabel); return true; diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp index 0ad6da036c..02dcdb51e7 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp @@ -48,7 +48,7 @@ MyPurchase::~MyPurchase() } } -MyPurchase* MyPurchase::sharedPurchase() +MyPurchase* MyPurchase::getInstance() { if (s_pPurchase == NULL) { s_pPurchase = new MyPurchase(); diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h index a5d2048864..8a52fbe19d 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h @@ -35,7 +35,7 @@ public: class MyPurchase { public: - static MyPurchase* sharedPurchase(); + static MyPurchase* getInstance(); static void purgePurchase(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp index 4d195d2952..217efd6b25 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp @@ -70,28 +70,28 @@ bool TestIAP::init() return false; } - MyPurchase::sharedPurchase()->loadIAPPlugin(); + MyPurchase::getInstance()->loadIAPPlugin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. EGLView* pEGLView = EGLView::getInstance(); - Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); - Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); + Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); + Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition( Point::ZERO ); this->addChild(pMenu, 1); - Point posStep = ccp(220, -150); - Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f)); + Point posStep = Point(220, -150); + Point beginPos = posTL + (posStep * 0.5f); int line = 0; int row = 0; for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { @@ -99,13 +99,13 @@ bool TestIAP::init() CC_CALLBACK_1(TestIAP::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); - Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); + Point pos = beginPos + Point(posStep.x * row, posStep.y * line); Size itemSize = pMenuItem->getContentSize(); if ((pos.x + itemSize.width / 2) > posBR.x) { line += 1; row = 0; - pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); + pos = beginPos + Point(posStep.x * row, posStep.y * line); } row += 1; pMenuItem->setPosition(pos); @@ -123,7 +123,7 @@ void TestIAP::eventMenuCallback(Object* pSender) pInfo["productPrice"] = "0.01"; pInfo["productDesc"] = "100个金灿灿的游戏币哦"; pInfo["Nd91ProductId"] = "685994"; - MyPurchase::sharedPurchase()->payByMode(pInfo, mode); + MyPurchase::getInstance()->payByMode(pInfo, mode); } void TestIAP::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp index 0d631924a8..7dc0460263 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp @@ -49,7 +49,7 @@ MyIAPOLManager::~MyIAPOLManager() } } -MyIAPOLManager* MyIAPOLManager::sharedManager() +MyIAPOLManager* MyIAPOLManager::getInstance() { if (s_pIAPOnline == NULL) { s_pIAPOnline = new MyIAPOLManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h index b508cef1cf..f64749b01f 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h @@ -36,7 +36,7 @@ public: class MyIAPOLManager { public: - static MyIAPOLManager* sharedManager(); + static MyIAPOLManager* getInstance(); static void purge(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp index e8d59f9953..6d2315b64a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp @@ -74,7 +74,7 @@ bool TestIAPOnline::init() return false; } - MyIAPOLManager::sharedManager()->loadPlugins(); + MyIAPOLManager::getInstance()->loadPlugins(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -153,7 +153,7 @@ void TestIAPOnline::eventMenuCallback(Object* pSender) // pInfo["QHAppOrderID"] = "Order ID in game"; // The order ID in game (Game defined this) } - MyIAPOLManager::sharedManager()->payByMode(pInfo, mode); + MyIAPOLManager::getInstance()->payByMode(pInfo, mode); } void TestIAPOnline::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp index 97f6d34174..11cd6a70aa 100644 --- a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp @@ -48,7 +48,7 @@ MyShareManager::~MyShareManager() } } -MyShareManager* MyShareManager::sharedManager() +MyShareManager* MyShareManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MyShareManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h index 4521a57b6c..cd8202f3a3 100755 --- a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h @@ -35,7 +35,7 @@ public: class MyShareManager { public: - static MyShareManager* sharedManager(); + static MyShareManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp index 1be29f9439..cf2a308f2c 100644 --- a/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp @@ -70,7 +70,7 @@ bool TestShare::init() return false; } - MyShareManager::sharedManager()->loadSharePlugin(); + MyShareManager::getInstance()->loadSharePlugin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -120,7 +120,7 @@ void TestShare::eventMenuCallback(Object* pSender) pInfo["SharedText"] = "Share message : HelloShare!"; // pInfo["SharedImagePath"] = "Full/path/to/image"; MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1); - MyShareManager::sharedManager()->shareByMode(pInfo, mode); + MyShareManager::getInstance()->shareByMode(pInfo, mode); } void TestShare::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp index 97ed27f872..21d790296a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp @@ -41,7 +41,7 @@ MySocialManager::~MySocialManager() unloadPlugins(); } -MySocialManager* MySocialManager::sharedManager() +MySocialManager* MySocialManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MySocialManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h index 69cfee5bba..4df5026163 100755 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h @@ -29,7 +29,7 @@ THE SOFTWARE. class MySocialManager : public cocos2d::plugin::SocialListener { public: - static MySocialManager* sharedManager(); + static MySocialManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp b/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp index 2415ca6dd9..a8f1c7e9e3 100644 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp @@ -59,7 +59,7 @@ bool TestSocial::init() return false; } - MySocialManager::sharedManager()->loadPlugins(); + MySocialManager::getInstance()->loadPlugins(); Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); @@ -119,7 +119,7 @@ bool TestSocial::init() void TestSocial::testSubmit(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->submitScore((MySocialManager::MySocialMode)(nIdx + 1), "0", 30000); + MySocialManager::getInstance()->submitScore((MySocialManager::MySocialMode)(nIdx + 1), "0", 30000); } void TestSocial::testUnlock(Object* pSender) @@ -129,19 +129,19 @@ void TestSocial::testUnlock(Object* pSender) info["AchievementID"] = "MyAchiID"; info["NDDisplayText"] = "Fighter"; info["NDScore"] = "100"; - MySocialManager::sharedManager()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info); + MySocialManager::getInstance()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info); } void TestSocial::testLeaderboard(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->showLeaderboard((MySocialManager::MySocialMode)(nIdx + 1), "0"); + MySocialManager::getInstance()->showLeaderboard((MySocialManager::MySocialMode)(nIdx + 1), "0"); } void TestSocial::testAchievement(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1)); + MySocialManager::getInstance()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1)); } void TestSocial::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp index d0f5e653ec..3c63bd8091 100644 --- a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp @@ -49,7 +49,7 @@ MyUserManager::~MyUserManager() } } -MyUserManager* MyUserManager::sharedManager() +MyUserManager* MyUserManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MyUserManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h index 721367661d..83ad696372 100755 --- a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h @@ -36,7 +36,7 @@ public: class MyUserManager { public: - static MyUserManager* sharedManager(); + static MyUserManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp index 20aa643c1a..aebb5d2e0a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp @@ -60,7 +60,7 @@ bool TestUser::init() return false; } - MyUserManager::sharedManager()->loadPlugin(); + MyUserManager::getInstance()->loadPlugin(); Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); @@ -117,12 +117,12 @@ void TestUser::caseChanged(Object* pSender) void TestUser::testLogin(Object* pSender) { - MyUserManager::sharedManager()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); + MyUserManager::getInstance()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } void TestUser::testLogout(Object* pSender) { - MyUserManager::sharedManager()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); + MyUserManager::getInstance()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } void TestUser::menuBackCallback(Object* pSender)