我是初学者,学习LibGDX.我正在LibGDX开发我的第一个游戏,你可以用选定的图片替换敌人的球(例如某人的头部)然后你躲避敌人.在我的主菜单中我有stage2d按钮,我想有一个按钮,让用户选择他
编辑:
所以,假设我的核心项目中有一个界面:
public interface OpenGallery {
public void openGallery();
}
在我的android目录中,我创建了一个特定于Platform的类来启动intent
import android.content.Intent;
import com.kubas.zaidimas.OpenGallery;
public class GalleryOpener extends AndroidLauncher implements OpenGallery {
private static final int SELECT_PICTURE = 1;
@Override
public void openGallery() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
从这一点起我该怎么办?所以我可以在我的主菜单中调用它?
我创建了一个示例libgdx项目,其中包含特定于android的代码,用于调用库并检索用户选择的图像的文件路径.希望这有助于您了解集成的工作原理.我在几个Android设备上测试过它.见 https://github.com/miket-ap/libgdx-platform-specific-example
