Questions For Game Designing

How To Make Flappy Bird
  • MoseHas
    Likes 0

    Problem Description

    Hi, it is me again.

    I have some questions here.

    1. I have seen tons of   
    Director::getInstance();

              usages in the code. I looked up for the definition.

    • Director: Class that creates and handles the main Window and manages how and when to execute the Scenes.
    • getInstance: Returns a shared instance of the director.

    It seems like Director::getInstance is so powerful that it can control the entire scene. 

    Like:

    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);

    p.s. this is in GameScene.cpp of Flappy Bird project.

    I feel I get confused what it is actually doing. And also the listener is what drives me nuts. 

    How should I establish the concept about all these?  I want to fully understand them so that I would not get stuck while I am designing my own game.

     

         2.  I am studying another game project now, which is called PopStar. It is about a 10x10, 5 different color bricks and we doubleclick to eliminate the same color bricks nearby.

             You could see the actual demostration here: https://www.youtube.com/watch?v=gpOn51O9Azo

             I have already had some thoughts about its algorithm, but I do not know how to implement them on Cocos2d-x, like using an array to store Sprite and I can simply adjust the index value to determine the upper/lower/left/right brick has the same color as the chosen one. Would you mind showing me a direction that the better way to implement this project?

     

         3.  Is it right that defining an object with auto and we do not have to care about whether it is a value or a pointer? Because I have seen someone else’s code and he wrote like this:

    CCSprite* sprite = CCSprite::create("sprite.png");

    And I create my sprite using:

    auto sprite = Sprite::create("sprite.png");

    And both they call setPosition with:

    sprite->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));

    Is it correct that I declare auto sprite to be a pointer even if I do not use * ?

     

     

        4.  When do we have to use class destructor? I sometimes saw it but not really understand what it is for.

     

    Sorry that I have too many questions. I really want to be a good cocos2d-x programmer. Hope you can help me out.

    Huge appreciation!


  • Sonar Systems admin
    Likes 0

    1. Regarding this don’t worry yourself about it, that’s once of the many reason we use engines, check this link out for more info though http://www.cocos2d-x.org/wiki/Director
    2. A 2D array would be best
    3. auto sprite = is the same as CCSprite *sprite and Sprite *sprite
    4. Class destructor for scenes or your own custom classes?

    This reply has been verified.
  • MoseHas
    Likes 0

    Since I am not a native speaker, I feel myself hardly to express what I am worry about. I do not think I really understand what Director::getInstance() is doing even if I checked every single explanaion or definition.

     

    Yes, I figure out a 2D array for implement. But I do not know how to make the array built by sprites and align them. Not even mention deleting a brick or making them drop by gravity.

     

    My confuse is sometimes I saw people write things in the destructor but sometimes they left it blank. That made me awkward. It seems that the destructor is unnecessary for every program, it is?


    This reply has been verified.
  • MoseHas
    Likes 0

    Thanks! This really helps.

    I feel I have more questions with my new needs, and I think I will post them in a new article.


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Yes a new article would be best for new questions, feel free to post away :D


    This reply has been verified.

Login to reply