| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "frontend.h" | 5 #include "frontend.h" |
| 6 #include "app_delegate.h" | 6 #include "app_delegate.h" |
| 7 #include "gameplay_scene.h" | 7 #include "game_manager.h" |
| 8 | 8 |
| 9 #include "CCLuaEngine.h" | 9 #include "CCLuaEngine.h" |
| 10 | 10 |
| 11 USING_NS_CC; | 11 USING_NS_CC; |
| 12 | 12 |
| 13 const int kFontSize = 24; | 13 const int kFontSize = 24; |
| 14 const int kFontSizeLarge = 48; | 14 const int kFontSizeLarge = 48; |
| 15 const char* kFontName = "Arial.ttf"; | 15 const char* kFontName = "Arial.ttf"; |
| 16 | 16 |
| 17 bool FrontEndScene::init() { | 17 bool FrontEndScene::init() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 assert(item_index == items->count()); | 61 assert(item_index == items->count()); |
| 62 | 62 |
| 63 menu->setPosition(ccp(origin.x, origin.y)); | 63 menu->setPosition(ccp(origin.x, origin.y)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void FrontEndLayer::LevelSelected(CCObject* sender) { | 66 void FrontEndLayer::LevelSelected(CCObject* sender) { |
| 67 int level = ((CCMenuItem*)sender)->getTag(); | 67 int level = ((CCMenuItem*)sender)->getTag(); |
| 68 CCLog("LevelSelected: %d", level); | 68 CCLog("LevelSelected: %d", level); |
| 69 CCTransitionScene* transition; | 69 GameManager::sharedManager()->LoadLevel(level); |
| 70 CCDirector* director = CCDirector::sharedDirector(); | |
| 71 | |
| 72 // transition to a new (autorelease) GameplayScene. | |
| 73 CCScene* scene = GameplayScene::create(level); | |
| 74 director->setDepthTest(true); | |
| 75 transition = CCTransitionPageTurn::create(1.0f, scene, false); | |
| 76 director->pushScene(transition); | |
| 77 } | 70 } |
| 78 | 71 |
| 79 void FrontEndLayer::AddChildAligned(CCNode* node, int height) { | 72 void FrontEndLayer::AddChildAligned(CCNode* node, int height) { |
| 80 CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); | 73 CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); |
| 81 CCSize visible_size = CCDirector::sharedDirector()->getVisibleSize(); | 74 CCSize visible_size = CCDirector::sharedDirector()->getVisibleSize(); |
| 82 CCSize node_size = node->getContentSize(); | 75 CCSize node_size = node->getContentSize(); |
| 83 // A negative height means an offet from the top of the visible area | 76 // A negative height means an offet from the top of the visible area |
| 84 if (height < 0) | 77 if (height < 0) |
| 85 height += visible_size.height; | 78 height += visible_size.height; |
| 86 float xpos = origin.x + visible_size.width / 2; | 79 float xpos = origin.x + visible_size.width / 2; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 155 |
| 163 // Position Menu | 156 // Position Menu |
| 164 CCSize visible_size = CCDirector::sharedDirector()->getVisibleSize(); | 157 CCSize visible_size = CCDirector::sharedDirector()->getVisibleSize(); |
| 165 CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); | 158 CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); |
| 166 menu->alignItemsVertically(); | 159 menu->alignItemsVertically(); |
| 167 float xpos = origin.x + visible_size.width/2; | 160 float xpos = origin.x + visible_size.width/2; |
| 168 float ypos = origin.y + visible_size.height/2; | 161 float ypos = origin.y + visible_size.height/2; |
| 169 menu->setPosition(ccp(xpos, ypos)); | 162 menu->setPosition(ccp(xpos, ypos)); |
| 170 return true; | 163 return true; |
| 171 } | 164 } |
| OLD | NEW |