How use dt variable of update() method

How use dt variable of update() method
0.0 0


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


Use float:
virtual void update(float dt);


but then how can i get seconds from float variable


This float variable is time in seconds. If dt == 1.0f then it means that exactly 1 second has passed.


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;
    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);