im having this code
void jigso_Apple::update(cocos2d::CCTime dt)
{
CCLOG (“in timer %f”,dt);
totaltime = apple_totaltime + dt; ///here im gating error (invalid operands to binary expression (‘cocos2d::CCTime’ and ‘cocos2d::CCTime’)
}
whre totaltime var is coco2d::CCTime totaltime
plz solve the above error
neno
#2
Use float:
virtual void update(float dt);
but then how can i get seconds from float variable
neno
#4
This float variable is time in seconds. If dt == 1.0f then it means that exactly 1 second has passed.
lucas0
#5
how can i call my update function every 5 seconds?
i tried to do:
void TitleScene::update(float dt){
if (dt - lastTimeUpdateWasCalled_ < 5.0) return;
/*
routine
*/
lastTimeUpdateWasCalled = dt;
}
but i dont think dt is the time stamp… so my if doesnt work the way i supposed…
Just schedule the function like
this->schedule(schedule_selector(TitleScene::tick), 5.0f);