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

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
Index: nacltoons/src/FrontEnd.cc
diff --git a/nacltoons/src/FrontEnd.cc b/nacltoons/src/FrontEnd.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ebd583d455b71a8eb7b337d6d18ceec238d1f123
--- /dev/null
+++ b/nacltoons/src/FrontEnd.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 The Native Client 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;
+}
+
binji 2013/02/12 22:51:53 nit: one space here and below
Sam Clegg 2013/02/12 23:07:38 Done
+
+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,
binji 2013/02/12 22:51:53 nit: move start_label to next line, or wrap the fo
Sam Clegg 2013/02/12 23:07:38 Done.
+ 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;
+}

Powered by Google App Engine
This is Rietveld 408576698