Rename the singleton methods name in sample project of plugin.

Remove the deprecated methods.
This commit is contained in:
zhangbin 2013-07-24 15:31:20 +08:00
parent a718f8ba81
commit 9944a5d186
17 changed files with 46 additions and 46 deletions

View File

@ -89,8 +89,8 @@ bool TestAds::init()
Size visibleSize = Director::getInstance()->getVisibleSize(); Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); Point origin = Director::getInstance()->getVisibleOrigin();
Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
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 // 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 // add a "close" icon to exit the progress. it's an autorelease object
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this)); MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this));
Size backSize = pBackItem->getContentSize(); 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 // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pBackItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
@ -107,15 +107,15 @@ bool TestAds::init()
LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24); LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this)); 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); pMenu->addChild(pItemShow, 0);
pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120))); pItemShow->setPosition(posMid + Point(-100, -120));
LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24); LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24);
MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this)); 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); pMenu->addChild(pItemHide, 0);
pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120))); pItemHide->setPosition(posMid + Point(100, -120));
// create optional menu // create optional menu
// cases item // cases item
@ -127,7 +127,7 @@ bool TestAds::init()
{ {
_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) ); _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); pMenu->addChild(_caseItem);
// type item // type item
@ -139,7 +139,7 @@ bool TestAds::init()
{ {
_typeItem->getSubItems()->addObject( MenuItemFont::create( s_aTestTypes[i].c_str() ) ); _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); pMenu->addChild(_typeItem);
// poses item // poses item
@ -151,7 +151,7 @@ bool TestAds::init()
{ {
_posItem->getSubItems()->addObject( MenuItemFont::create( s_aTestPoses[i].c_str() ) ); _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); pMenu->addChild(_posItem);
// init options // init options

View File

@ -89,7 +89,7 @@ bool TestAnalytics::init()
Size visibleSize = Director::getInstance()->getVisibleSize(); Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); 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 // 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 // add a "close" icon to exit the progress. it's an autorelease object
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this)); MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this));
Size backSize = pBackItem->getContentSize(); 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 // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pBackItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
@ -111,15 +111,15 @@ bool TestAnalytics::init()
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this)); MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
yPos = visibleSize.height - 35*i - 100; 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 strName = _pluginAnalytics->getPluginName();
std::string strVer = _pluginAnalytics->getSDKVersion(); std::string strVer = _pluginAnalytics->getSDKVersion();
char ret[256] = { 0 }; char ret[256] = { 0 };
sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(visibleSize.width, 0), kTextAlignmentCenter); LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), kTextAlignmentCenter);
pLabel->setPosition(ccp(visibleSize.width / 2, yPos - 80)); pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80));
addChild(pLabel); addChild(pLabel);
return true; return true;

View File

@ -48,7 +48,7 @@ MyPurchase::~MyPurchase()
} }
} }
MyPurchase* MyPurchase::sharedPurchase() MyPurchase* MyPurchase::getInstance()
{ {
if (s_pPurchase == NULL) { if (s_pPurchase == NULL) {
s_pPurchase = new MyPurchase(); s_pPurchase = new MyPurchase();

View File

@ -35,7 +35,7 @@ public:
class MyPurchase class MyPurchase
{ {
public: public:
static MyPurchase* sharedPurchase(); static MyPurchase* getInstance();
static void purgePurchase(); static void purgePurchase();
typedef enum { typedef enum {

View File

@ -70,28 +70,28 @@ bool TestIAP::init()
return false; return false;
} }
MyPurchase::sharedPurchase()->loadIAPPlugin(); MyPurchase::getInstance()->loadIAPPlugin();
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // you may modify it.
EGLView* pEGLView = EGLView::getInstance(); EGLView* pEGLView = EGLView::getInstance();
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); 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 // add a "close" icon to exit the progress. it's an autorelease object
MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this)); MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this));
Size backSize = pBackItem->getContentSize(); 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 // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pBackItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
pMenu->setPosition( Point::ZERO ); pMenu->setPosition( Point::ZERO );
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
Point posStep = ccp(220, -150); Point posStep = Point(220, -150);
Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f)); Point beginPos = posTL + (posStep * 0.5f);
int line = 0; int line = 0;
int row = 0; int row = 0;
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { 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)); CC_CALLBACK_1(TestIAP::eventMenuCallback, this));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); 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(); Size itemSize = pMenuItem->getContentSize();
if ((pos.x + itemSize.width / 2) > posBR.x) if ((pos.x + itemSize.width / 2) > posBR.x)
{ {
line += 1; line += 1;
row = 0; row = 0;
pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); pos = beginPos + Point(posStep.x * row, posStep.y * line);
} }
row += 1; row += 1;
pMenuItem->setPosition(pos); pMenuItem->setPosition(pos);
@ -123,7 +123,7 @@ void TestIAP::eventMenuCallback(Object* pSender)
pInfo["productPrice"] = "0.01"; pInfo["productPrice"] = "0.01";
pInfo["productDesc"] = "100个金灿灿的游戏币哦"; pInfo["productDesc"] = "100个金灿灿的游戏币哦";
pInfo["Nd91ProductId"] = "685994"; pInfo["Nd91ProductId"] = "685994";
MyPurchase::sharedPurchase()->payByMode(pInfo, mode); MyPurchase::getInstance()->payByMode(pInfo, mode);
} }
void TestIAP::menuBackCallback(Object* pSender) void TestIAP::menuBackCallback(Object* pSender)

View File

@ -49,7 +49,7 @@ MyIAPOLManager::~MyIAPOLManager()
} }
} }
MyIAPOLManager* MyIAPOLManager::sharedManager() MyIAPOLManager* MyIAPOLManager::getInstance()
{ {
if (s_pIAPOnline == NULL) { if (s_pIAPOnline == NULL) {
s_pIAPOnline = new MyIAPOLManager(); s_pIAPOnline = new MyIAPOLManager();

View File

@ -36,7 +36,7 @@ public:
class MyIAPOLManager class MyIAPOLManager
{ {
public: public:
static MyIAPOLManager* sharedManager(); static MyIAPOLManager* getInstance();
static void purge(); static void purge();
typedef enum { typedef enum {

View File

@ -74,7 +74,7 @@ bool TestIAPOnline::init()
return false; return false;
} }
MyIAPOLManager::sharedManager()->loadPlugins(); MyIAPOLManager::getInstance()->loadPlugins();
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 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) // 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) void TestIAPOnline::menuBackCallback(Object* pSender)

View File

@ -48,7 +48,7 @@ MyShareManager::~MyShareManager()
} }
} }
MyShareManager* MyShareManager::sharedManager() MyShareManager* MyShareManager::getInstance()
{ {
if (s_pManager == NULL) { if (s_pManager == NULL) {
s_pManager = new MyShareManager(); s_pManager = new MyShareManager();

View File

@ -35,7 +35,7 @@ public:
class MyShareManager class MyShareManager
{ {
public: public:
static MyShareManager* sharedManager(); static MyShareManager* getInstance();
static void purgeManager(); static void purgeManager();
typedef enum { typedef enum {

View File

@ -70,7 +70,7 @@ bool TestShare::init()
return false; return false;
} }
MyShareManager::sharedManager()->loadSharePlugin(); MyShareManager::getInstance()->loadSharePlugin();
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 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["SharedText"] = "Share message : HelloShare!";
// pInfo["SharedImagePath"] = "Full/path/to/image"; // pInfo["SharedImagePath"] = "Full/path/to/image";
MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1); 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) void TestShare::menuBackCallback(Object* pSender)

View File

@ -41,7 +41,7 @@ MySocialManager::~MySocialManager()
unloadPlugins(); unloadPlugins();
} }
MySocialManager* MySocialManager::sharedManager() MySocialManager* MySocialManager::getInstance()
{ {
if (s_pManager == NULL) { if (s_pManager == NULL) {
s_pManager = new MySocialManager(); s_pManager = new MySocialManager();

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
class MySocialManager : public cocos2d::plugin::SocialListener class MySocialManager : public cocos2d::plugin::SocialListener
{ {
public: public:
static MySocialManager* sharedManager(); static MySocialManager* getInstance();
static void purgeManager(); static void purgeManager();
typedef enum { typedef enum {

View File

@ -59,7 +59,7 @@ bool TestSocial::init()
return false; return false;
} }
MySocialManager::sharedManager()->loadPlugins(); MySocialManager::getInstance()->loadPlugins();
Size visibleSize = Director::getInstance()->getVisibleSize(); Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); Point origin = Director::getInstance()->getVisibleOrigin();
@ -119,7 +119,7 @@ bool TestSocial::init()
void TestSocial::testSubmit(Object* pSender) void TestSocial::testSubmit(Object* pSender)
{ {
int nIdx = _caseItem->getSelectedIndex(); 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) void TestSocial::testUnlock(Object* pSender)
@ -129,19 +129,19 @@ void TestSocial::testUnlock(Object* pSender)
info["AchievementID"] = "MyAchiID"; info["AchievementID"] = "MyAchiID";
info["NDDisplayText"] = "Fighter"; info["NDDisplayText"] = "Fighter";
info["NDScore"] = "100"; info["NDScore"] = "100";
MySocialManager::sharedManager()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info); MySocialManager::getInstance()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info);
} }
void TestSocial::testLeaderboard(Object* pSender) void TestSocial::testLeaderboard(Object* pSender)
{ {
int nIdx = _caseItem->getSelectedIndex(); 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) void TestSocial::testAchievement(Object* pSender)
{ {
int nIdx = _caseItem->getSelectedIndex(); int nIdx = _caseItem->getSelectedIndex();
MySocialManager::sharedManager()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1)); MySocialManager::getInstance()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1));
} }
void TestSocial::menuBackCallback(Object* pSender) void TestSocial::menuBackCallback(Object* pSender)

View File

@ -49,7 +49,7 @@ MyUserManager::~MyUserManager()
} }
} }
MyUserManager* MyUserManager::sharedManager() MyUserManager* MyUserManager::getInstance()
{ {
if (s_pManager == NULL) { if (s_pManager == NULL) {
s_pManager = new MyUserManager(); s_pManager = new MyUserManager();

View File

@ -36,7 +36,7 @@ public:
class MyUserManager class MyUserManager
{ {
public: public:
static MyUserManager* sharedManager(); static MyUserManager* getInstance();
static void purgeManager(); static void purgeManager();
typedef enum { typedef enum {

View File

@ -60,7 +60,7 @@ bool TestUser::init()
return false; return false;
} }
MyUserManager::sharedManager()->loadPlugin(); MyUserManager::getInstance()->loadPlugin();
Size visibleSize = Director::getInstance()->getVisibleSize(); Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin(); Point origin = Director::getInstance()->getVisibleOrigin();
Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); 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) void TestUser::testLogin(Object* pSender)
{ {
MyUserManager::sharedManager()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); MyUserManager::getInstance()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1));
} }
void TestUser::testLogout(Object* pSender) void TestUser::testLogout(Object* pSender)
{ {
MyUserManager::sharedManager()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); MyUserManager::getInstance()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1));
} }
void TestUser::menuBackCallback(Object* pSender) void TestUser::menuBackCallback(Object* pSender)