In C++ code of EasyNDK sameple:
https://github.com/aajiwani/EasyNDK-for-cocos2dx/blob/master/Classes/HelloWorldScene.cpp
You can see the EasyNDK for cocos2d-x 3 version too:
there is a way to expect a call from Java
of ObjectiveC
your function such as:
/*
* Register selectors in a global space so the native environment can
* respond to the selector when the specified method is called
* NOTE: Group name is used to easily remove selectors
*/
NDKHelper::addSelector("HelloWorldSelectors",
"gameTestMethod",
CC_CALLBACK_2(HelloWorld::gameTestMethod, this),
this);
Here the third parameter is FuncNV
where:
typedef std::function<void(cocos2d::Node *, cocos2d::Value)> FuncNV;
I wonder what if I have a purchase manager or other manager that does not need to be a child of Node but should get messages back from the specific platforms. How I should set callbacks correctly?
For example, in case of sending a message you can do that without a Node
// Finally call the native method in current environment
SendMessageWithParams(string("SampleSelector"), prms);
You write the function name and parameters, and it doesn’t matter who is the superclass of your class form which you send a message.