2012-04-19 14:35:52 +08:00
|
|
|
|
#include "testBasic.h"
|
|
|
|
|
#include "controller.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
|
#include "extensions/cocos-ext.h"
|
2013-10-16 11:19:01 +08:00
|
|
|
|
#include "cocostudio/CocoStudio.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
TestScene::TestScene(bool bPortrait)
|
|
|
|
|
{
|
2013-09-10 17:41:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TestScene::initTest()
|
|
|
|
|
{
|
|
|
|
|
return Scene::init();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestScene::onEnter()
|
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
|
Scene::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
|
|
//add the menu item for back to main menu
|
|
|
|
|
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
2013-08-16 16:05:27 +08:00
|
|
|
|
// auto label = LabelBMFont::create("MainMenu", "fonts/arial16.fnt");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
//#else
|
2013-08-16 16:05:27 +08:00
|
|
|
|
auto label = LabelTTF::create("MainMenu", "Arial", 20);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
//#endif
|
2013-08-16 16:05:27 +08:00
|
|
|
|
auto menuItem = MenuItemLabel::create(label, [](Object *sender) {
|
2013-06-08 10:25:53 +08:00
|
|
|
|
/*
|
|
|
|
|
****** GCC Compiler issue on Android and Linux (CLANG compiler is ok) ******
|
2013-06-20 14:17:10 +08:00
|
|
|
|
We couldn't use 'Scene::create' directly since gcc will trigger
|
2013-06-08 10:25:53 +08:00
|
|
|
|
an error called "error: 'this' was not captured for this lambda function".
|
2013-06-20 14:17:10 +08:00
|
|
|
|
This is because 'Scene' is the super class of TestScene, if we invoke 'Scene::create'
|
|
|
|
|
directly in this lambda expression, gcc compiler found 'Scene::create' and it think
|
2013-06-08 10:25:53 +08:00
|
|
|
|
that was the member function of 'TestScene' 's super class, but this lambda function doesn't
|
2013-06-20 14:17:10 +08:00
|
|
|
|
capture anything like 'this', so it has no access to invoke 'Scene::create'.
|
2013-06-08 10:25:53 +08:00
|
|
|
|
|
|
|
|
|
Solution (1): Passing 'this' to this lambda function.
|
2013-06-20 14:17:10 +08:00
|
|
|
|
Solution (2): Don't use 'Scene::create' and don't pass 'this' to this lambda function,
|
|
|
|
|
instead, we just need to new the 'Scene' and initialize the Scene.
|
2013-06-08 10:25:53 +08:00
|
|
|
|
|
|
|
|
|
Semantically, I think in this lambda function, we shouldn't capture any varibles
|
|
|
|
|
outside the scope. So I choose the (2) solution. Commented by James Chen.
|
|
|
|
|
*/
|
2013-06-08 08:21:11 +08:00
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
|
// auto scene = Scene::create();
|
|
|
|
|
auto scene = new Scene();
|
2013-07-23 08:25:44 +08:00
|
|
|
|
if (scene && scene->init())
|
2013-06-08 10:25:53 +08:00
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
|
auto layer = new TestController();
|
2013-07-23 08:25:44 +08:00
|
|
|
|
scene->addChild(layer);
|
|
|
|
|
layer->release();
|
|
|
|
|
Director::getInstance()->replaceScene(scene);
|
|
|
|
|
scene->release();
|
2013-06-08 10:25:53 +08:00
|
|
|
|
}
|
2013-09-17 23:03:33 +08:00
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
|
cocostudio::ArmatureDataManager::destoryInstance();
|
2013-06-08 08:21:11 +08:00
|
|
|
|
});
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
|
auto menu =Menu::create(menuItem, NULL);
|
2012-10-23 17:48:50 +08:00
|
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
|
menu->setPosition( Point::ZERO );
|
|
|
|
|
menuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
|
addChild(menu, 1);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
}
|