在libgdx管理桌面和设备版本之间的资产 [英] Managing assets between desktop and device version in libgdx

查看:157
本文介绍了在libgdx管理桌面和设备版本之间的资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个小的Andr​​oid游戏使用libgdx。 现在我有比赛的资产在桌面项目文件夹的副本和Android项目文件夹。由于一些奇怪的原因,我有不同的访问分别在两个版本的文件。

I'm building a little Android game using libgdx. For now I have a copy of the game's assets in the desktop project folder and the Android project folder. For some strange reason I have to access those files differently in each of the two versions.

这工作正常,在桌面应用程序,但给了我一个FileNotFound异常的Andr​​oid应用程序:

This works fine in the desktop app but gives me a FileNotFound exception in the android app:

Texture texture = new Texture(Gdx.files.internal("assets/someImage.png"));

如果我从文件名中去掉了资产这是另一种方式圆(Android的工程,桌面崩溃):

If I remove the "assets" from the filename it's the other way round (Android works, desktop crashes):

Texture texture = new Texture(Gdx.files.internal("someImage.png"));

我不知道是什么问题。该文件夹结构是完全一样的两个项目... 正确的方法是什么这与libgdx?

I'm not sure what the problem is. The folder structure is exactly the same for both projects... What is the right way to this with libgdx?

推荐答案

您应该保存您的所有资产在Android资产文件夹和桌面项目链接到该文件夹​​。有这样一个简单描述<一href="http://www.badlogicgames.com/word$p$pss/?p=1537">http://www.badlogicgames.com/word$p$pss/?p=1537

You should be storing all of your assets in the Android assets folder and linking your desktop project to that folder. There is a quick description of this at http://www.badlogicgames.com/wordpress/?p=1537

编辑:官方项目设置教程介绍了如何执行这一点。它在<一个发现href="http://$c$c.google.com/p/libgdx/wiki/ProjectSetup#Asset_folder_setup">http://$c$c.google.com/p/libgdx/wiki/ProjectSetup#Asset_folder_setup

The official Project Setup tutorial describes how to perform this as well. It's found at http://code.google.com/p/libgdx/wiki/ProjectSetup#Asset_folder_setup

除了项目设置我相信,你的第二个方法是从两个项目的参考资产的正确途径。当您解决您的设置应该在两种环境中正常工作。

Aside from project setup I believe that your second method is the correct way of referencing the assets from both projects. After you fix your setup it should work properly in both environments.

这篇关于在libgdx管理桌面和设备版本之间的资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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