I am developing games and facing problem with creating timer. I need some logic like time should start from 60 sec when it reach to 0 game should end. I am new to this platform.
How to create timer in my games in cocos2dx using c++ [closed]
I usually use the scheduler for this, which you can use to call a method at fixed time intervals, like this:
this->schedule(schedule_selector(Game::UpdateTimer),1.0f);
in this case it calls 'Game:UpdateTimer' once a second. In update timer you'd just reduce your counter by one, and when it's reach zero stop the timer like this:
this->unschedule( schedule_selector(Game::UpdateTimer));
and add a method underneath to be called
void Game::UpdateTimer(float dt)
{
}
© 2022 - 2024 — McMap. All rights reserved.
std::thread
and writing a Timer class. I usually create astd::vector
ofstd::threads
and they all run at their proper intervals and I can get to them easily to manipulate. If you accepted more answers people provide they might give you more help. – Imp