我正在尝试将 Swarm 集成到我的游戏中,但它不起作用,我正在使用andengine GLES2。我想要的只是一个排行榜集成,如果我将它作为一个单独的活动来扩展 SwarmActivity(如果它有效),但我想将它集成到 BaseGameActivity 中。
谢谢你。
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
}
};