Answer the question
In order to leave comments, you need to log in
How to pass a function as a parameter to another function?
Coconut has an ActionFloat class, and it has a function:
static ActionFloat* create(float duration, float from, float to, ActionFloatCallback callback);
typedef std::function<void(float value)> ActionFloatCallback;
MyClass::MyClass()
{
ActionFloat* floatAction = ActionFloat::create(0.5f, 0, 1, this->callback); // так не работает
//ActionFloat* floatAction = ActionFloat::create(0.5f, 0, 1, testFunc); // так работает
}
void MyClass::callback(float t)
{
CCLOG("test: %f", t);
}
void testFunc(float t)
{
CCLOG("test: %f", t);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question