2010-08-06 17:50:20 +08:00
|
|
|
#include "testBasic.h"
|
2010-08-09 18:07:50 +08:00
|
|
|
#include "controller.h"
|
2010-08-06 17:50:20 +08:00
|
|
|
|
2010-08-09 18:07:50 +08:00
|
|
|
BackToMainMenuLayer::BackToMainMenuLayer()
|
2010-08-06 17:50:20 +08:00
|
|
|
{
|
2010-08-09 18:07:50 +08:00
|
|
|
//add the menu item for back to main menu
|
2010-08-17 15:01:09 +08:00
|
|
|
CCLabel* label = CCLabel::labelWithString("MainMenu", "Arial", 20);
|
|
|
|
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(BackToMainMenuLayer::MainMenuCallback));
|
2010-08-09 18:07:50 +08:00
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL);
|
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
pMenu->setPosition( CGPointZero );
|
|
|
|
pMenuItem->setPosition( CGPointMake( s.width - 50, 25) );
|
2010-08-09 18:07:50 +08:00
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
addChild(pMenu, 1);
|
2010-08-06 17:50:20 +08:00
|
|
|
}
|
|
|
|
|
2010-08-17 15:01:09 +08:00
|
|
|
void BackToMainMenuLayer::MainMenuCallback(NSObject* pSender)
|
|
|
|
{
|
|
|
|
CCScene* pScene = CCScene::node();
|
|
|
|
CCLayer* pLayer = new TestController();
|
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
pScene->addChild(pLayer);
|
|
|
|
CCDirector::getSharedDirector()->replaceScene(pScene);
|
|
|
|
}
|
2010-08-09 18:07:50 +08:00
|
|
|
|
2010-08-06 17:50:20 +08:00
|
|
|
TestScene::TestScene()
|
|
|
|
{
|
2010-09-02 15:15:45 +08:00
|
|
|
CCScene::init();
|
2010-08-09 18:07:50 +08:00
|
|
|
CCLayer* pLayer = new BackToMainMenuLayer();
|
2010-08-06 17:50:20 +08:00
|
|
|
pLayer->autorelease();
|
|
|
|
|
2010-08-25 14:22:48 +08:00
|
|
|
addChild(pLayer, 1000);
|
2010-08-06 17:50:20 +08:00
|
|
|
}
|