0
我正在致力於一個項目Cocos2d-x(最新)其中我使用Google Play遊戲服務,當我嘗試集成Google Play時遇到了幾個問題使用C++的服務,然後我決定改用JAVA。從Java JNI調用C++函數 - Cocos2d-x
當用戶點擊該按鈕「邀請朋友」,該方法startGame()用JNI調用成功,但沒有發生!以下場景不顯示。
C++代碼:
extern "C"
{
JNIEXPORT void JNICALL Java_sonar_systems_frameworks_GooglePlayServices_GooglePlayServicesGameHelper_startGame(JNIEnv* env, jobject thiz);
};
JNIEXPORT void JNICALL Java_sonar_systems_frameworks_GooglePlayServices_GooglePlayServicesGameHelper_startGame(JNIEnv* env, jobject thiz)
{
MenuScene::goToScene();
}
void MenuScene::goToScene() {
//Going to the next scene
Scene * gameScene=GameScene::createScene();
TransitionFade*transition=TransitionFade::create(TRANSITION_TIME, gameScene);
//Replace the current Scene with New Game Scene
Director::getInstance()->replaceScene(transition);
}
的Java代碼從那裏上述函數被調用:
private native void startGame();
public void inviteFriend() {
startGame();
// launch the player selection screen
// minimum: 1 other player; maximum: 3 other players
//Intent intent = Games.RealTimeMultiplayer.getSelectOpponentsIntent(mGoogleApiClient, 1, 1);
//((Activity) GooglePlayServices.ctx).startActivityForResult(intent, RC_SELECT_PLAYERS);
}
C之間的通訊++和Java是好的,但爲什麼我不能去到下一個場景,代碼是正確的!
謝謝