Browse Source

Arrumando appdelegate

capellaresumo 7 years ago
parent
commit
7b6e2fa9eb

+ 14 - 6
Classes/BeginScene.cpp

@@ -1,3 +1,12 @@
+/********************************************************************
+ *  Nomes: Gabriel Capella                       Números USP: 8962078 
+ *         João Herique Luciano                               8535957
+ * 
+ *  Tarefa:    RedCore - EP2 MAC0463
+ *  Arquivo:   BeginScene.cpp
+ *  Descrição: Classe para tela inicial do jogo.
+ ********************************************************************/
+
 #include "BeginScene.h"
 #include "GameScene.h"
 #include "SimpleAudioEngine.h"
@@ -34,8 +43,7 @@ Scene* BeginScene::createScene() {
 }
 
 bool BeginScene::init() {
-    //////////////////////////////
-    // 1. super init first
+
     if (!Layer::init()) {
         return false;
     }
@@ -47,7 +55,7 @@ bool BeginScene::init() {
     auto bg = cocos2d::LayerColor::create(COLOR_back);
     this->addChild(bg);
     
-    auto menu_item_start = MenuItemFont::create(MSG_START, CC_CALLBACK_1(BeginScene::Play, this));
+    auto menu_item_start = MenuItemFont::create(MSG_START, CC_CALLBACK_0(BeginScene::Play, this));
     menu_item_start->setFontNameObj(FONT);
     
     menu_item_start->setPosition(Point(visibleSize.width / 2, (visibleSize.height*0.25)));
@@ -95,7 +103,7 @@ bool BeginScene::init() {
     userdata->setDoubleForKey("time", last);
     userdata->setIntegerForKey("level", level);
     
-    this->levels = level;
+    this->level_game = level;
     
     char level_text[256];
     if (level != 0) {
@@ -109,8 +117,8 @@ bool BeginScene::init() {
     return true;
 }
 
-void BeginScene::Play(cocos2d::Ref *pSender) {
-    auto scene = GameScene::createScene(this->levels);
+void BeginScene::Play() {
+    auto scene = GameScene::createScene(this->level_game);
     Director::getInstance()->replaceScene(scene);
 }
 

+ 36 - 2
Classes/BeginScene.h

@@ -1,3 +1,12 @@
+/********************************************************************
+ *  Nomes: Gabriel Capella                       Números USP: 8962078 
+ *         João Herique Luciano                               8535957
+ * 
+ *  Tarefa:    RedCore - EP2 MAC0463
+ *  Arquivo:   BeginScene.h
+ *  Descrição: Classe para tela inicial do jogo.
+ ********************************************************************/
+
 #ifndef __BEGIN_SCENE_H__
 #define __BEGIN_SCENE_H__
 
@@ -5,12 +14,37 @@
 
 class BeginScene: public cocos2d::Layer {
     public:
+    	/**
+    	 * Inicia tela do jogo.
+    	 * @return um Scene. Veja mais na documentação do cocos2d-x.
+    	 */
         static cocos2d::Scene* createScene();
+
+        /**
+         * Sobreesvreve o método padrão da classe. Serve para
+         * inicializar a cena.
+         * @return se conseguiu ou não iniciar
+         */
         virtual bool init();
-        void Play(Ref *pSender);
+
+        /**
+         * Inicia o jogo jogável. Vai para GameScene.
+         */
+        void Play();
+
+        /**
+         * É um macro do cocos2d-x que define a função create do
+         * do classe.
+         * 
+         * @param Classe para qual vai criar.
+         */
         CREATE_FUNC(BeginScene);
     private:
-        int levels;
+    	/**
+    	 * Armazena qual o nível atual do jogador. Variável usada
+    	 * para fazer regressão de nível.
+    	 */
+        int level_game;
 };
 
 #endif // __BEGIN_SCENE_H__

+ 3 - 3
Classes/GameScene.cpp

@@ -199,7 +199,7 @@ void GameScene::caseBallCollision (Node *ball) {
         auto text = Label::createWithTTF(MSG_OVER, FONT, 40);
         text->setPosition(width/2, height/2);
         addChild(text);
-        auto menu_item_start = MenuItemFont::create(MSG_RESTART, CC_CALLBACK_1(GameScene::NextLevel, this));
+        auto menu_item_start = MenuItemFont::create(MSG_RESTART, CC_CALLBACK_0(GameScene::nextLevel, this));
         menu_item_start->setFontNameObj(FONT);
         menu_item_start->setPosition(text->getPosition());
         menu_item_start->setPositionY(menu_item_start->getPositionY()-50);
@@ -218,7 +218,7 @@ void GameScene::caseBallCore (Node *core, Node *ball) {
     
     auto callbackRotate = CallFunc::create([=](){
         level = level + 1;
-        auto menu_item_start = MenuItemFont::create(MSG_NEXT_LEVEL, CC_CALLBACK_1(GameScene::NextLevel, this));
+        auto menu_item_start = MenuItemFont::create(MSG_NEXT_LEVEL, CC_CALLBACK_0(GameScene::nextLevel, this));
         menu_item_start->setFontNameObj(FONT);
         menu_item_start->setPosition(Point(width / 2, (height / 2)));
         auto *menu = Menu::create(menu_item_start, NULL);
@@ -241,7 +241,7 @@ void GameScene::caseSaveLevel(Node *powerup_ball) {
     powerup_ball->removeFromParentAndCleanup(true);
 }
 
-void GameScene::NextLevel(Ref *pSender) {
+void GameScene::nextLevel() {
     auto scene = GameScene::createScene(level);
     Director::getInstance()->replaceScene(scene);
 }

+ 1 - 1
Classes/GameScene.h

@@ -24,7 +24,7 @@ class GameScene : public cocos2d::Layer {
         void caseBallCollision (cocos2d::Node *ball);
         void caseBallCore (cocos2d::Node *core, cocos2d::Node *ball);
         void caseSaveLevel(Node *powerup_ball);
-        void NextLevel(cocos2d::Ref *pSender);
+        void nextLevel();
         void saveLevel();
         void tripleBallsAppearance();
         void caseTripleBalls(Node *powerup_ball);

BIN
proj.ios_mac/RedCore.xcodeproj/project.xcworkspace/xcuserdata/capella.xcuserdatad/UserInterfaceState.xcuserstate