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

Unified Diff: nacltoons/src/FrontEnd.cc

Issue 12226130: [nacltoons] Add initial frontend and physics game scenes. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 10 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/FrontEnd.h ('k') | nacltoons/src/GameplayScene.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nacltoons/src/FrontEnd.cc
diff --git a/nacltoons/src/FrontEnd.cc b/nacltoons/src/FrontEnd.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0b73383c71219ad3f0807f86025d9364d895902
--- /dev/null
+++ b/nacltoons/src/FrontEnd.cc
@@ -0,0 +1,51 @@
+// 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() {
+ CCScene* scene = CCScene::create();
+ CCLayer* frontend = FrontEnd::create();
+ scene->addChild(frontend);
+ return scene;
+}
+
+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;
+}
« no previous file with comments | « nacltoons/src/FrontEnd.h ('k') | nacltoons/src/GameplayScene.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698