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

Unified Diff: nacltoons/src/gameplay_scene.cc

Issue 12220140: [nacltoons] Cleanup initial game code. (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/gameplay_scene.cc
diff --git a/nacltoons/src/gameplay_scene.cc b/nacltoons/src/gameplay_scene.cc
index afbe0548053364c6b1aef98e23c6e71d92842e72..df5f84c2a5f7148625d57ee04a01d449fabc3349 100644
--- a/nacltoons/src/gameplay_scene.cc
+++ b/nacltoons/src/gameplay_scene.cc
@@ -4,35 +4,38 @@
#include "gameplay_scene.h"
#include "physics_layer.h"
-#define PHYSICS_TAG 101
-#define UI_TAG 102
+/**
+ * Tags used by the GameplayScene to identify child elements. Actual values
+ * here are not important as long as they are unique within the scene.
+ */
+enum ObjectTags {
+ NODE_TAG_PHYSICS = 100,
+ NODE_TAG_UI
+};
USING_NS_CC;
-CCScene* Gameplay::scene() {
- return Gameplay::create();
-}
-
-void Gameplay::Restart() {
- removeChild(getChildByTag(PHYSICS_TAG));
+void GameplayScene::Restart() {
+ removeChild(getChildByTag(NODE_TAG_PHYSICS));
CCLayer* physics = PhysicsLayer::create();
- addChild(physics, 2, PHYSICS_TAG);
+ addChild(physics, 2, NODE_TAG_PHYSICS);
}
-bool Gameplay::init() {
+bool GameplayScene::init() {
if (!CCScene::init())
return false;
CCLayer* ui = UILayer::create();
- addChild(ui, 1, UI_TAG);
+ addChild(ui, 1, NODE_TAG_UI);
CCLayer* physics = PhysicsLayer::create();
- addChild(physics, 2, PHYSICS_TAG);
+ addChild(physics, 2, NODE_TAG_PHYSICS);
return true;
}
void UILayer::Restart(CCObject* sender) {
CCLog("Restart pressed");
- ((Gameplay*)getParent())->Restart();
+ GameplayScene* scene = static_cast<GameplayScene*>(getParent());
+ scene->Restart();
}
void UILayer::Exit(CCObject* sender) {
@@ -63,8 +66,8 @@ bool UILayer::init() {
CCSize label_size = restart_label->getContentSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
menu->alignItemsVertically();
- float xpos = origin.x + visibleSize.width*0.05 + label_size.width/2;
- float ypos = origin.y + visibleSize.height*0.95 - label_size.height;
+ float xpos = origin.x + visibleSize.width * 0.05 + label_size.width/2;
+ float ypos = origin.y + visibleSize.height * 0.95 - label_size.height;
menu->setPosition(ccp(xpos, ypos));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698