2012-04-16 18:58:43 +08:00
|
|
|
/*
|
|
|
|
* CCControlScene.m
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Yannick Loriot
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CCControlScene.h"
|
|
|
|
#include "CCControlSceneManager.h"
|
2012-04-18 13:58:24 +08:00
|
|
|
#include "../ExtensionsTest.h"
|
2012-04-16 18:58:43 +08:00
|
|
|
|
|
|
|
CCControlScene::CCControlScene()
|
|
|
|
: m_pSceneTitleLabel(NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CCControlScene::~CCControlScene()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(m_pSceneTitleLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCControlScene::init()
|
|
|
|
{
|
|
|
|
if (CCLayer::init())
|
|
|
|
{
|
2013-06-08 08:21:11 +08:00
|
|
|
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &CCControlScene::toExtensionsMainLayer, this, std::placeholders::_1));
|
2012-10-23 17:48:50 +08:00
|
|
|
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
pBackMenu->setPosition( CCPointZero );
|
2012-04-18 13:58:24 +08:00
|
|
|
addChild(pBackMenu, 10);
|
|
|
|
|
2012-04-16 18:58:43 +08:00
|
|
|
// Add the generated background
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSprite *background = CCSprite::create("extensions/background.png");
|
2012-10-23 17:48:50 +08:00
|
|
|
background->setPosition(VisibleRect::center());
|
2012-04-16 18:58:43 +08:00
|
|
|
addChild(background);
|
|
|
|
|
|
|
|
// Add the ribbon
|
2012-06-14 15:13:16 +08:00
|
|
|
CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55));
|
2012-10-23 17:48:50 +08:00
|
|
|
ribbon->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, 57));
|
|
|
|
ribbon->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f));
|
2012-04-16 18:58:43 +08:00
|
|
|
addChild(ribbon);
|
|
|
|
|
|
|
|
// Add the title
|
2012-06-14 15:13:16 +08:00
|
|
|
setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12));
|
2012-10-23 17:48:50 +08:00
|
|
|
m_pSceneTitleLabel->setPosition(ccp (VisibleRect::center().x, VisibleRect::top().y - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
|
2012-04-16 18:58:43 +08:00
|
|
|
addChild(m_pSceneTitleLabel, 1);
|
|
|
|
|
|
|
|
// Add the menu
|
2013-06-08 08:21:11 +08:00
|
|
|
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &CCControlScene::previousCallback, this, std::placeholders::_1));
|
|
|
|
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &CCControlScene::restartCallback, this, std::placeholders::_1));
|
|
|
|
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &CCControlScene::nextCallback, this, std::placeholders::_1));
|
2012-04-16 18:58:43 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
|
2012-04-16 18:58:43 +08:00
|
|
|
menu->setPosition(CCPointZero);
|
2012-10-23 17:48:50 +08:00
|
|
|
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
|
|
|
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
2012-04-16 18:58:43 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu ,1);
|
2012-04-18 13:58:24 +08:00
|
|
|
|
2012-04-16 18:58:43 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void CCControlScene::toExtensionsMainLayer(CCObject* sender)
|
|
|
|
{
|
|
|
|
ExtensionsTestScene* pScene = new ExtensionsTestScene();
|
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
2012-04-18 13:58:24 +08:00
|
|
|
}
|
|
|
|
|
2012-04-16 23:16:03 +08:00
|
|
|
void CCControlScene::previousCallback(CCObject* sender)
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->previousControlScene());
|
|
|
|
}
|
|
|
|
|
2012-04-16 23:16:03 +08:00
|
|
|
void CCControlScene::restartCallback(CCObject* sender)
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->currentControlScene());
|
|
|
|
}
|
|
|
|
|
2012-04-16 23:16:03 +08:00
|
|
|
void CCControlScene::nextCallback(CCObject* sender)
|
2012-04-16 18:58:43 +08:00
|
|
|
{
|
|
|
|
CCDirector::sharedDirector()->replaceScene(CCControlSceneManager::sharedControlSceneManager()->nextControlScene());
|
|
|
|
}
|
|
|
|
|