蓝牙在Android libgdx项目 [英] bluetooth in libgdx project on Android

查看:104
本文介绍了蓝牙在Android libgdx项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我一个忠告关于 libgdx 使用蓝牙游戏在Android?
我的问题是,整个code为MyGame项目,并在 MyGame-的Andr​​oid 只有 MainActivity 类启动Android上的游戏。

Can anyone give me a piece of advice about using bluetooth in libgdx games on Android? My problem is that the whole code is in MyGame project and in MyGame-Android there is only MainActivity class that starts the game on Android.

我可以得到蓝牙在正常Android应用程序的工作,但 MyGame libgdx 项目不能看到,在 MyGame-Android项目

I can get bluetooth to work in normal Android application but MyGame libgdx project can't see classes that are in MyGame-Android project.

推荐答案

如果您想使用libgdx非多code,你应该建立在不可知的项目(MyGame)的接口,并实现它的本地项目(MyGame-Android设备)。然后,在本地项目中创建实现者对象,并把它传递给MyGame实例。该接口将保留所有你说不是访问的方法(一个提示:尽量能够封装最多可以对蓝牙管理和揭露有关唯一方法,以你的游戏,所以你不必创造了巨大的接口)

If you want to use non-multiplatform code in libgdx, you should create an interface on the agnostic project (MyGame), and implement it on the native project (MyGame-Android). Then, on the native project create the implementor object and pass it to the MyGame instance. The interface will hold all the methods that you said are not accessible (a tip: try to can encapsulate the most you can regarding the bluetooth management and expose only methods relevant to your game, so you don't have to create a huge interface).

这篇关于蓝牙在Android libgdx项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆