Chromium Code Reviews| Index: nacltoons/src/FrontEnd.cc |
| diff --git a/nacltoons/src/FrontEnd.cc b/nacltoons/src/FrontEnd.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5deec37bd2ae52ef413cbeea5167def13f4a734a |
| --- /dev/null |
| +++ b/nacltoons/src/FrontEnd.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#include "FrontEnd.h" |
| +#include "GameplayScene.h" |
| + |
| +USING_NS_CC; |
| + |
| +CCScene* FrontEnd::scene() { |
|
noelallen1
2013/02/12 23:35:52
CreateScene() - otherwise this looks like an acces
|
| + CCScene* scene = CCScene::create(); |
| + CCLayer* frontend = FrontEnd::create(); |
|
noelallen1
2013/02/12 23:35:52
Are you instantiating something then throwing it a
|
| + scene->addChild(frontend); |
| + return scene; |
|
noelallen1
2013/02/12 23:35:52
Is a Layer a collection of Scenes or a Scene a col
|
| +} |
| + |
| + |
| +void FrontEnd::startGame(CCObject* sender) { |
| + CCLog("startGame pressed"); |
| + CCTransitionScene* transition; |
| + CCDirector* director = CCDirector::sharedDirector(); |
| + |
| + // transition to a new Gameplay scene. |
| + CCScene* scene = Gameplay::scene(); |
| + director->setDepthTest(true); |
| + transition = CCTransitionPageTurn::create(1.0f, scene, false); |
| + director->pushScene(transition); |
| +} |
| + |
| + |
| +bool FrontEnd::init() { |
| + if (!CCLayerColor::initWithColor(ccc4(0, 0xD8, 0x8F, 0xD8))) |
| + return false; |
| + |
| + setTouchEnabled(true); |
| + |
| + // Create and position the menu. |
| + CCLabelTTF* start_label = CCLabelTTF::create("Start Game", "Arial.ttf", 24); |
| + |
| + CCMenuItemLabel* start = CCMenuItemLabel::create(start_label, |
| + this, menu_selector(FrontEnd::startGame)); |
| + |
| + CCMenu* menu = CCMenu::create(start, NULL); |
| + addChild(menu); |
| + |
| + // Position Menu |
| + CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); |
| + CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); |
| + menu->alignItemsVertically(); |
| + float xpos = origin.x + visibleSize.width/2; |
| + float ypos = origin.y + visibleSize.height/2; |
| + menu->setPosition(ccp(xpos, ypos)); |
| + return true; |
| +} |