1

我正在为我的实时多人游戏使用 Google Play 游戏服务,但我无法从另一个不扩展 com.google.example.games.basegameutils.BaseGameActivity 的活动广播实时消息。

我扩展 BaseGameActivity 的活动 (MainActivity) 获得了一个静态实例,我从使用 Andengine 的其他活动 (RaceActivity) 中使用该实例。首先,我实例化我的 MainActivity 并在所有玩家都准备好时启动 RaceActivity。然后,在我的 RaceActivity 中,我从 MainActivity 中调用一个静态函数来广播一条消息,但它给了我这个异常:

06-02 14:55:04.585: E/AndroidRuntime(7961): FATAL EXCEPTION: UpdateThread
06-02 14:55:04.585: E/AndroidRuntime(7961): java.lang.IllegalStateException: Failed to send message, real-time match service is not connected.
06-02 14:55:04.585: E/AndroidRuntime(7961):     at android.os.Parcel.readException(Parcel.java:1433)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at android.os.Parcel.readException(Parcel.java:1379)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.google.android.gms.internal.bm$a$a.a(Unknown Source)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.google.android.gms.internal.bj.sendReliableRealTimeMessage(Unknown Source)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.google.android.gms.games.GamesClient.sendReliableRealTimeMessage(Unknown Source)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.MainActivity.broadcastMessage(MainActivity.java:371)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.GameScene.readyUp(GameScene.java:95)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.GameScene.createScene(GameScene.java:42)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.BaseScene.<init>(BaseScene.java:39)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.GameScene.<init>(GameScene.java:25)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at com.game.superninjarun.structure.SceneManager$1.onTimePassed(SceneManager.java:109)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.handler.timer.TimerHandler.onUpdate(TimerHandler.java:98)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.Engine.onUpdateUpdateHandlers(Engine.java:597)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.Engine.onUpdate(Engine.java:585)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
06-02 14:55:04.585: E/AndroidRuntime(7961):     at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)

有人知道什么是实时匹配服务吗?我什至在谷歌上都找不到...

4

1 回答 1

1

最后,感谢andengine 论坛上的这篇文章,我成功地将 Andengine 的 BaseGameActivity 和 Google 的 BaseGameUtils 合并。

我猜 GamesClient 类的功能只能在声明它的 Acvitity 中使用......

于 2013-06-03T03:20:49.197 回答