在Cocos2d Android中GameCircle集成时的白色补丁

时间:2014-07-08 16:07:26

标签: android cocos2d-android amazon-gamecircle

我正在整合Game Circle SDK&在我的游戏中悄悄话同步。我已经实现了代码,但它引起了一个问题。当我加载游戏并从WhisperSync获取游戏状态并设置我的局部变量时,在某些地方随机观察到白色斑块而不是正确的图像。当我转向GameCircle& Whisper Sync运行正常。

我的游戏是使用Cocos2d Android开发的。

有人遇到过这样的问题吗?

我已附上图片以供参考。

enter image description here

一些代码:

@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));
}

1 个答案:

答案 0 :(得分:0)

通过使用布尔变量解决它,并在firstsync / alreadysync方法中加载数据后将其设置为true。并在主线程中加载场景而不是低声同步的回调。很高兴知道是否有人找到了合适的解决方案。