Hello every body,
I want to make a countdown but I never managed to initialise a timer, how can i do that in C++, I see on other forum but it’s all in “objective c” so i never found the syntax to do that… i try this but it doesn’t work
In MyClass.cpp
this->schedule(schedule_selector(MyClass::TimeDisplay),1.0);
void MyClass::TimeDisplay(CCTime dt){
}
In MyClass.h
void TimeDisplay(CCTime dt);
Thanks a lot in advance
Best regards
1 Like
You can find solution in standart cocos2d-x example. Find it in standart tests, file IntervalTest.cpp, and modify.
Here corrections:
In MyClass.cpp
countdown = 1000;
m_label1 = CCLabelBMFont::labelWithString(“1000”, “fonts/bitmapFontTest4.fnt”);
this~~>schedule,1.0);
void MyClass::TimeDisplay{
countdown —;
char str[10] = ;
sprintf;
m_label1~~>setString( str );
}
In MyClass.h
void TimeDisplay(CCTime dt);
int countdown;
CCLabelBMFont* m_label1;
Great i will try it thakns a lot !
i have one variable TOTAL_TIME……i want to add that variable into dt in update method ….how can i do that….Help me