Flappy Bird Tutorial Questions

  • koko82
    Likes 0

    Problem Description

    Hi

     

    I’ve been looking at your flappy birds tutorials (very good bythe way). However its raised a couple of questions…

    1. The pipe creation doesnt seem to get removed from layer? Is this intentional?
    2. Why are you using schedule once parameter in onTouchBegan instead of just bird->Stopflying() theres also a float dt is that calling in BIRD_FLY_DURATION before it changes the bool statement?
    bool GameScene::onTouchBegan( cocos2d::Touch *touch, cocos2d::Event *event )
    {
        bird->Fly( );
        
        this->scheduleOnce( schedule_selector( GameScene::StopFlying ), BIRD_FLY_DURATION );
        
        return true;
    }
    
    void GameScene::StopFlying( float dt )
    {
        bird->StopFlying( );
    }

     

  • Sonar Systems admin
    Likes 0

    We use the scheduler so the stop flying code can be called after the bird has flown for a short period.

     

    The dt is delta time and is to be used for stuff like animation but the scheduler requires it, we don’t actually use it. BIRD_FLY_DURATION is how long after to call the StopFlying method.

  • koko82
    Likes 0

    Hi Thanks for response, what about the pipe creation, there is nothing to remove it? Or have I missed something….

    also then does this require a float dt? Or are you saying that dt parameter is required for the scheduleOnce… seems a bit pointless if the BIRD_FLY_DURATION  is the value used before the method is called. Doesnt make logical sense to have float dt as a required parameter for the method.

    void GameScene::StopFlying( float dt )

  • Sonar Systems admin
    Likes 0

    Pipe isn’t removed, it’s an extra task for you to do.

    dt is required for the scheduler, Cocos passes it dt itself.

  • koko82
    Likes 0

    Thanks for the help. Are there any more DIY’s?

    Also when you create a new Bird in game seen your allocating memory via stack does this not need a delete statement anywhere or does cocos2d-x automatically do this when scene is replaced? Or do you need to add a de-constructor the in bird class and “delete bird”    

    bird = new Bird( this );

     


  • Sonar Systems admin
    Likes 0

    DIY’s as in make your own game? If so yes we are planning a Tic-Tac-Toe game right now with achievements and ad support.

     

    Delete would be useful, small extra tasks for the viewer.

  • koko82
    Likes 0

    Cool, where you doing a 3d tutoral series too?

     

    Would you add the delete as a de-construct in the bird for example or in main game loop    

     

    bird::~bird
    {
      delete Bird;
    }

     

  • Sonar Systems admin
    Likes 0

    Deconstructor sounds good.  

     

    We are doing a 3D series soon.

  • Wicky_Ticky
    Likes 0

    Hey I’ve been following your flappy bird tutorial, and I keep getting the error message down below. 

     

     

    Undefined symbols for architecture x86_64:

      "AssetManager::AssetManager()", referenced from:

          std::__1::shared_ptr<GameData> std::__1::shared_ptr<GameData>::make_shared<>() in Game.o

      "AssetManager::~AssetManager()", referenced from:

          std::__1::shared_ptr<GameData> std::__1::shared_ptr<GameData>::make_shared<>() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::__on_zero_shared() in Game.o

      "InputManager::InputManager()", referenced from:

          std::__1::shared_ptr<GameData> std::__1::shared_ptr<GameData>::make_shared<>() in Game.o

      "InputManager::~InputManager()", referenced from:

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::__on_zero_shared() in Game.o

      "StateMachine::StateMachine()", referenced from:

          std::__1::shared_ptr<GameData> std::__1::shared_ptr<GameData>::make_shared<>() in Game.o

      "StateMachine::~StateMachine()", referenced from:

          std::__1::shared_ptr<GameData> std::__1::shared_ptr<GameData>::make_shared<>() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::~__shared_ptr_emplace() in Game.o

          std::__1::__shared_ptr_emplace<GameData, std::__1::allocator<GameData> >::__on_zero_shared() in Game.o

    ld: symbol(s) not found for architecture x86_64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

     

  • Sonar Systems admin
    Likes 0

    @Wicky_Ticky please post this as a separate question

Login to reply