Warning fixes for TestCpp. Using lambda, CC_CALLBACK_1 and clone pattern.

This commit is contained in:
James Chen 2013-06-21 14:15:20 +08:00
parent 56f8ab2675
commit dcaa55e622
5 changed files with 23 additions and 28 deletions

View File

@ -80,7 +80,12 @@ cocos2d::Node* ComponentsTestLayer::createGameScene()
root->addChild(player, 1, 1);
MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(ComponentsTestLayer::toExtensionsMainLayer,this));
MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){
ExtensionsTestScene *pScene = new ExtensionsTestScene();
pScene->runThisTest();
pScene->release();
});
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
Menu *menuBack = Menu::create(itemBack, NULL);
@ -92,14 +97,6 @@ cocos2d::Node* ComponentsTestLayer::createGameScene()
return root;
}
void ComponentsTestLayer::toExtensionsMainLayer(cocos2d::Object *sender)
{
ExtensionsTestScene *pScene = new ExtensionsTestScene();
pScene->runThisTest();
pScene->release();
}
void runComponentsTestLayerTest()
{
Scene *pScene = ComponentsTestLayer::scene();

View File

@ -24,9 +24,6 @@ public:
// init scene
cocos2d::Node* createGameScene();
//back to Extensions Main Layer
void toExtensionsMainLayer(cocos2d::Object *sender);
};
#endif // __HELLOWORLD_SCENE_H__

View File

@ -73,7 +73,12 @@ bool GameOverLayer::init()
NULL));
MenuItemFont *itemBack = MenuItemFont::create("Back", this, menu_selector(ComponentsTestLayer::toExtensionsMainLayer));
MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){
ExtensionsTestScene *pScene = new ExtensionsTestScene();
pScene->runThisTest();
pScene->release();
});
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
Menu *menuBack = Menu::create(itemBack, NULL);

View File

@ -37,13 +37,13 @@ WebSocketTestLayer::WebSocketTestLayer()
// Send Text
LabelTTF *labelSendText = LabelTTF::create("Send Text", "Arial", 22);
MenuItemLabel *itemSendText = MenuItemLabel::create(labelSendText, this, menu_selector(WebSocketTestLayer::onMenuSendTextClicked));
MenuItemLabel *itemSendText = MenuItemLabel::create(labelSendText, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendTextClicked, this));
itemSendText->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - SPACE));
menuRequest->addChild(itemSendText);
// Send Binary
LabelTTF *labelSendBinary = LabelTTF::create("Send Binary", "Arial", 22);
MenuItemLabel *itemSendBinary = MenuItemLabel::create(labelSendBinary, this, menu_selector(WebSocketTestLayer::onMenuSendBinaryClicked));
MenuItemLabel *itemSendBinary = MenuItemLabel::create(labelSendBinary, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendBinaryClicked, this));
itemSendBinary->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE));
menuRequest->addChild(itemSendBinary);
@ -67,7 +67,7 @@ WebSocketTestLayer::WebSocketTestLayer()
this->addChild(_errorStatus);
// Back Menu
MenuItemFont *itemBack = MenuItemFont::create("Back", this, menu_selector(WebSocketTestLayer::toExtensionsMainLayer));
MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(WebSocketTestLayer::toExtensionsMainLayer, this));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
Menu *menuBack = Menu::create(itemBack, NULL);
menuBack->setPosition(PointZero);

View File

@ -279,8 +279,7 @@ void TextureMipMap::onEnter()
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
ActionInterval* sc_back = scale1->reverse();
EaseOut* scale2 = (EaseOut*) (scale1->copy());
scale2->autorelease();
EaseOut* scale2 = scale1->clone();
ActionInterval* sc_back2 = scale2->reverse();
img0->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
@ -330,8 +329,7 @@ void TexturePVRMipMap::onEnter()
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
ActionInterval* sc_back = scale1->reverse();
EaseOut* scale2 = (EaseOut*) (scale1->copy());
scale2->autorelease();
EaseOut* scale2 = scale1->clone();
ActionInterval* sc_back2 = scale2->reverse();
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
@ -374,8 +372,7 @@ void TexturePVRMipMap2::onEnter()
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
ActionInterval* sc_back = scale1->reverse();
EaseOut* scale2 = (EaseOut*) (scale1->copy());
scale2->autorelease();
EaseOut* scale2 = scale1->clone();
ActionInterval* sc_back2 = scale2->reverse();
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
@ -1277,8 +1274,7 @@ void TextureAlias::onEnter()
ScaleBy* sc = ScaleBy::create(3, 8.0f);
ScaleBy* sc_back = (ScaleBy*) (sc->reverse());
RepeatForever* scaleforever = RepeatForever::create(Sequence::create(sc, sc_back, NULL));
RepeatForever* scaleToo = (RepeatForever*) (scaleforever->copy());
scaleToo->autorelease();
RepeatForever* scaleToo = scaleforever->clone();
sprite2->runAction(scaleforever);
sprite->runAction(scaleToo);
@ -1374,10 +1370,10 @@ void TexturePixelFormat::onEnter()
FadeIn* fadein = FadeIn::create(2);
Sequence* seq = Sequence::create(DelayTime::create(2), fadeout, fadein, NULL);
RepeatForever* seq_4ever = RepeatForever::create(seq);
RepeatForever* seq_4ever2 = (RepeatForever*) (seq_4ever->copy()); seq_4ever2->autorelease();
RepeatForever* seq_4ever3 = (RepeatForever*) (seq_4ever->copy()); seq_4ever3->autorelease();
RepeatForever* seq_4ever4 = (RepeatForever*) (seq_4ever->copy()); seq_4ever4->autorelease();
RepeatForever* seq_4ever5 = (RepeatForever*) (seq_4ever->copy()); seq_4ever5->autorelease();
RepeatForever* seq_4ever2 = seq_4ever->clone();
RepeatForever* seq_4ever3 = seq_4ever->clone();
RepeatForever* seq_4ever4 = seq_4ever->clone();
RepeatForever* seq_4ever5 = seq_4ever->clone();
sprite1->runAction(seq_4ever);
sprite2->runAction(seq_4ever2);