我正在使用Google Play游戏服务进行实时多人游戏,但我无法播放其他未扩展com.google.example.games.basegameutils.BaseGameActivity的活动的实时消息。< / p>
扩展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)
有人知道实时匹配服务到底是什么吗?我甚至无法在谷歌上找到它......
答案 0 :(得分:1)
最后,由于post on the andengine forum,我设法合并了Andengine的BaseGameActivity和Google的BaseGameUtils。
我想GamesClient类的功能只能在声明它的Acvitity中使用...