Reputation: 144
Hey guys i am using schedule_selecter in cocos2dx project, where i am having 7 different int values. I am generating random value among these 7 values. Now i want to pass this random value to another function after some interval. I am using schedule_selecter to make call after some interval but it does not allow me to pass value. how can i do this???
ex.
int random_val = arc4random() % 7;
...
function_selected_value(int random_val) { .... }
i want to pass random_val to function_selected_value using schedule_selecter
thnx in advance ..
Upvotes: 0
Views: 560
Reputation: 43359
schedule_selecter
does not allow you to pass any data with functor. Instead you can assign value to any member variable and access there in callback function.
// scheduling a function with interval of 1 seconds.
float interval = 1.0f; // interval to call scheduler function.
CCNode::schedule(schedule_selector(MyClass::scheduleFunction), interval);
void MyClass::scheduleFunction(float dt) {
// use your random number related code here
}
Upvotes: 1