Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: nacltoons/src/game_manager.cc

Issue 12579005: [nacltoons] Rename core classes in accordance with doc. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nacltoons/src/game_manager.h ('k') | nacltoons/src/gameplay_scene.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nacltoons/src/game_manager.cc
diff --git a/nacltoons/src/game_manager.cc b/nacltoons/src/game_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..601f9e7847754ae2d3c65fadecffff09e6088faf
--- /dev/null
+++ b/nacltoons/src/game_manager.cc
@@ -0,0 +1,61 @@
+// 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 "game_manager.h"
+#include "level_layer.h"
+#include "ui_layer.h"
+
+USING_NS_CC;
+
+GameManager* GameManager::sharedManager()
+{
+ static GameManager* shared_manager = NULL;
+ if (!shared_manager)
+ shared_manager = new GameManager();
+ return shared_manager;
+}
+
+void GameManager::CreateLevel(CCScene* scene)
+{
+ CCLayer* level = LevelLayer::create(level_number_);
+ scene->addChild(level, 1, TAG_LAYER_LEVEL);
+}
+
+void GameManager::Restart(CCScene* scene)
+{
+ scene->removeChild(scene->getChildByTag(TAG_LAYER_LEVEL));
+ scene->removeChild(scene->getChildByTag(TAG_LAYER_OVERLAY));
+ CreateLevel(scene);
+}
+
+void GameManager::LoadLevel(int level_number)
+{
+ CCDirector* director = CCDirector::sharedDirector();
+ CCTransitionScene* transition;
+ level_number_ = level_number;
+ CCScene* scene = CCScene::create();
+ CCLayer* ui = UILayer::create();
+ scene->addChild(ui, 3, TAG_LAYER_UI);
+
+ CreateLevel(scene);
+
+ director->setDepthTest(true);
+ transition = CCTransitionPageTurn::create(1.0f, scene, false);
+ director->pushScene(transition);
+}
+
+void GameManager::GameOver(CCScene* scene, bool success) {
+ CCSize visible_size = CCDirector::sharedDirector()->getVisibleSize();
+
+ // Create a black overlay layer with success/failure message
+ CCLayer* overlay = CCLayerColor::create(ccc4(0x0, 0x0, 0x0, 0x0));
+ const char* text = success ? "Success!" : "Failure!";
+ CCLabelTTF* label = CCLabelTTF::create(text, "Arial.ttf", 24);
+ label->setPosition(ccp(visible_size.width/2, visible_size.height/2));
+ overlay->addChild(label);
+ scene->addChild(overlay, 2, TAG_LAYER_OVERLAY);
+
+ // Face the overlay layer into to 50%
+ CCActionInterval* fadein = CCFadeTo::create(0.5f, 0x7F);
+ overlay->runAction(fadein);
+}
« no previous file with comments | « nacltoons/src/game_manager.h ('k') | nacltoons/src/gameplay_scene.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698