0

I am integrating Game Circle SDK & Whisper Sync in my game. I have implemented the code, but it has caused an issue. When I load the game and get the game state from the WhisperSync and set my local variables, white patches are observed in some places randomly instead of the proper image. When I turn of GameCircle & Whisper Sync it runs fine.

My game is developed using Cocos2d Android.

Does any one encountered such issue?

I have attached the image for reference.

enter image description here

Some Code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    CCGLSurfaceView _glSurfaceView = new CCGLSurfaceView(this);

    setContentView(_glSurfaceView);

    CCDirector.sharedDirector().attachInView(_glSurfaceView);

    CCDirector.sharedDirector().setDisplayFPS(false);

    CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);

    CCScene scene = IntroLayer.scene();

    CCDirector.sharedDirector().runWithScene(scene);
}

@Override
public void onResume() {
    super.onResume();

    if (IS_AMAZON) {

        AmazonGamesClient.initialize(this, callback, myGameFeatures);
        AmazonGamesClient.getWhispersyncClient()
                .setWhispersyncEventListener(
                        new WhispersyncEventListener() {

                            @Override
                            public void onAlreadySynchronized() {
                                // TODO Auto-generated method stub
                                super.onAlreadySynchronized();
                                System.out
                                        .println("FA here onAlreadySynchronized");
                                loadGameScene();
                            }

                            @Override
                            public void onDataUploadedToCloud() {
                                // TODO Auto-generated method stub
                                super.onDataUploadedToCloud();
                                System.out
                                        .println("FA here onDataUploadedToCloud");
                            }

                            @Override
                            public void onDiskWriteComplete() {
                                // TODO Auto-generated method stub
                                super.onDiskWriteComplete();
                                System.out
                                        .println("FA here onDiskWriteComplete");
                            }

                            @Override
                            public void onFirstSynchronize() {
                                // TODO Auto-generated method stub
                                super.onFirstSynchronize();
                                System.out
                                        .println("FA here onFirstSynchronize");
                                loadGameScene();
                            }

                            @Override
                            public void onNewCloudData() {
                                // TODO Auto-generated method stub
                                super.onNewCloudData();
                                System.out
                                        .println("FA here onNewCloudData");
                            }

                            @Override
                            public void onSyncFailed(FailReason reason) {
                                // TODO Auto-generated method stub
                                super.onSyncFailed(reason);
                                System.out
                                        .println("FA here onSyncFailed reason: "
                                                + reason.name());
                            }

                            @Override
                            public void onThrottled() {
                                // TODO Auto-generated method stub
                                super.onThrottled();
                                System.out.println("FA here onThrottled");
                            }

                        });
        Log.i(TAG, "onResume: call initiateGetUserIdRequest");
        PurchasingManager.initiateGetUserIdRequest();

        Log.i(TAG, "onResume: call initiateItemDataRequest for skus: "
                + LAppInfo.getInstance().getList());
        Set<String> skus = new HashSet<String>(LAppInfo.getInstance()
                .getList());
        PurchasingManager.initiateItemDataRequest(skus);
    }
    CCDirector.sharedDirector().resume();
}

private AmazonGamesCallback callback = new AmazonGamesCallback() {
    @Override
    public void onServiceNotReady(AmazonGamesStatus status) {
        // unable to use service
        System.out.println("FA here callback onServiceNotReady: "
                + status.name());
    }

    @Override
    public void onServiceReady(AmazonGamesClient amazonGamesClient) {
        System.out.println("FA here callback onServiceReady: ");
        agsClient = amazonGamesClient;
    }
};

private void loadGameScene() {
    LoadData();
    CCScene mainMenu = LevelMenuScene.scene();
    CCDirector.sharedDirector().replaceScene(
            CCFadeTransition.transition(0.5f, mainMenu));
}
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Farooq Arshed
  • 1,984
  • 2
  • 17
  • 26

1 Answers1

0

Solved it by a work around by having a boolean variable and set it to true after the data is loaded in firstsync/alreadysync method. and loading the scene in the main thread instead of the callback of whispersync. Will be glad to know if some one find a proper solution.

Farooq Arshed
  • 1,984
  • 2
  • 17
  • 26