0

I'd like to know if Its possible to interact with Cocos2d-x Scene?

Like if I press the button, I can call a method inside Cocos2d-x, for example to start an animation.

If yes, please provide me a sample.

enter image description here

Marckaraujo
  • 7,422
  • 11
  • 59
  • 97

2 Answers2

0

Yes, it's possible. So on iOS: it's very simple, you just need to import the C++ header file in your objective c(mm file) and call. You might need to save the instance somewhere. This still applies to cocos2d-x - Calling C++ method from Objective C

Android: You need to define JNI function on C++ side and call from java. Please refer this link : http://stnguyen.com/cocos2d-x/call-cpp-functions-from-java.html

Community
  • 1
  • 1
christian
  • 445
  • 1
  • 3
  • 12
  • yes, its possible. But its not really easy, you need to create a bridge to Objective-C++ then another to swift. – Marckaraujo Jan 15 '17 at 16:21
0

For exchanging information between native layer and cocos2d-x versions 3.x and higher you can use this project:

https://github.com/alfonsocejudo/EasyNDK-for-cocos2dx3

It works well for Android, iOS and OSX.

kuvukala
  • 66
  • 7