Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #include "FrontEnd.h" | |
| 5 #include "GameplayScene.h" | |
| 6 | |
| 7 USING_NS_CC; | |
| 8 | |
| 9 CCScene* FrontEnd::scene() { | |
|
noelallen1
2013/02/12 23:35:52
CreateScene() - otherwise this looks like an acces
| |
| 10 CCScene* scene = CCScene::create(); | |
| 11 CCLayer* frontend = FrontEnd::create(); | |
|
noelallen1
2013/02/12 23:35:52
Are you instantiating something then throwing it a
| |
| 12 scene->addChild(frontend); | |
| 13 return scene; | |
|
noelallen1
2013/02/12 23:35:52
Is a Layer a collection of Scenes or a Scene a col
| |
| 14 } | |
| 15 | |
| 16 | |
| 17 void FrontEnd::startGame(CCObject* sender) { | |
| 18 CCLog("startGame pressed"); | |
| 19 CCTransitionScene* transition; | |
| 20 CCDirector* director = CCDirector::sharedDirector(); | |
| 21 | |
| 22 // transition to a new Gameplay scene. | |
| 23 CCScene* scene = Gameplay::scene(); | |
| 24 director->setDepthTest(true); | |
| 25 transition = CCTransitionPageTurn::create(1.0f, scene, false); | |
| 26 director->pushScene(transition); | |
| 27 } | |
| 28 | |
| 29 | |
| 30 bool FrontEnd::init() { | |
| 31 if (!CCLayerColor::initWithColor(ccc4(0, 0xD8, 0x8F, 0xD8))) | |
| 32 return false; | |
| 33 | |
| 34 setTouchEnabled(true); | |
| 35 | |
| 36 // Create and position the menu. | |
| 37 CCLabelTTF* start_label = CCLabelTTF::create("Start Game", "Arial.ttf", 24); | |
| 38 | |
| 39 CCMenuItemLabel* start = CCMenuItemLabel::create(start_label, | |
| 40 this, menu_selector(FrontEnd::startGame)); | |
| 41 | |
| 42 CCMenu* menu = CCMenu::create(start, NULL); | |
| 43 addChild(menu); | |
| 44 | |
| 45 // Position Menu | |
| 46 CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); | |
| 47 CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); | |
| 48 menu->alignItemsVertically(); | |
| 49 float xpos = origin.x + visibleSize.width/2; | |
| 50 float ypos = origin.y + visibleSize.height/2; | |
| 51 menu->setPosition(ccp(xpos, ypos)); | |
| 52 return true; | |
| 53 } | |
| OLD | NEW |