Hi.
at 3.6 release CallFuncND is deprecated and documentation recommends use CallFuncN but there is no parameter pass as it have CallFuncND, what to do?
Hi.
at 3.6 release CallFuncND is deprecated and documentation recommends use CallFuncN but there is no parameter pass as it have CallFuncND, what to do?
You can store the data part in node->setUserData(void*) or node->setUserObject(Ref*). Then when you use CallFuncN you can extract the data from the node.
ok, thanks
You can also bind data using lambda capture, or with std::bind + std::function + std::placeholders. You may have to worry about anything that is captured or bound being a pointer or reference that may get deleted or released before the callback executes.
i am not from C++ world, so i dont understand what it means
Oh, sorry, yeah you can ignore my last reply then. You might not need to know about them for now (or ever) since you can just use the helper macros: CC_CALLBACK_0, CC_CALLBACK_1, etc.
node->runAction( CallFuncN::create( CC_CALLBACK_1(MyClass::method, this) ) );
Eventually you might want to learn about lamdas and std::function family in order to best understand how the UI events, Action callbacks, and scheduled functions work. There’s likely a similar concept with different terminology if you’ve come from another language (closure, block, etc)
yes i use macros callbacks everywhere.
ok i will read about lambdas and functions, thank you.