0
我正在嘗試在我的遊戲中集成Swarm,但它不起作用,我正在使用andengine GLES2。我想要的只是一個排行榜集成,如果我將它作爲一個獨立的活動來擴展SwarmActivity(如果它能工作的話),但我想將它集成到BaseGameActivity中。將swarm集成到引擎中
謝謝。
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
// TODO Auto-generated method stub
//Cargo la escena del Cargando
mScene = new Scene();
mScene.setBackgroundEnabled(false);
mScene.attachChild(new Sprite(0, 0, mSplashBackgroundTextureRegion, this.getVertexBufferObjectManager()));
this.mScene.setOnSceneTouchListener(this);
this.mScene.setTouchAreaBindingOnActionDownEnabled(true);
Swarm.init(this, SWARM_APP_ID, SWARM_APP_KEY, mySwarmLoginListener);
Swarm.setActive(this);
pOnCreateSceneCallback.onCreateSceneFinished(this.mScene);
}
public boolean onSceneTouchEvent(Scene arg0, TouchEvent arg1) {
// TODO Auto-generated method stub
SwarmLeaderboard.getLeaderboardById(LEADERBOARD_ID, new GotLeaderboardCB() {
public void gotLeaderboard(SwarmLeaderboard leaderboard) {
if (leaderboard != null) {
// Save a local reference to the leaderboard
SwActivity.leaderboard = leaderboard;
// Submit the score to the leaderboard
SwActivity.leaderboard.submitScore(1000f);
SwActivity.leaderboard.showLeaderboard();
}
}
});
return false;
}
public void onResume() {
super.onResume();
Swarm.setActive(this);
}
public void onPause() {
super.onPause();
Swarm.setInactive(this);
}
private SwarmLoginListener mySwarmLoginListener = new SwarmLoginListener() {
public void loginCanceled() {
// TODO Auto-generated method stub
}
public void loginStarted() {
// TODO Auto-generated method stub
}
public void userLoggedIn(SwarmActiveUser user) {
// Load our Leaderboard
SwarmLeaderboard.getLeaderboardById(LEADERBOARD_ID, new GotLeaderboardCB() {
public void gotLeaderboard(SwarmLeaderboard lb) {
leaderboard = lb;
}
});
}
public void userLoggedOut() {
// TODO Auto-generated method stub
}
};