很抱歉打扰你,我知道这个问题已经有人问过了,但我无法解决。我已经开始使用libgdx,并决定有一本书作为教程--“学习LigbGDX游戏开发”。这一切都很好,直到第4章,我不能装载资产到峡谷邦尼。包。我不知道发生了什么事。在../canyonbunny-android/assets/images中创建了两个文件-一个是png,另一个是atlas。如果你能帮我一把,我将非常欢迎。
DesktopLauncher.java
package com.packtub.libgdx.canyonbunny.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.packtub.libgdx.canyonbunny.CanyonBunnyMain;
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings;
public class DesktopLauncher {
private static boolean rebuildAtlas = true;
private static boolean drawDebugOutline = true;
public static void main (String[] args) {
if (rebuildAtlas){
Settings settings = new Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.debug = drawDebugOutline;
TexturePacker.process(settings, "assets-raw/images",
"..CanyonBunny-android/assets/images",
"canyonbunny.pack");
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "CanyonBunny";
config.useGL30 = false;
config.width = 800;
config.height = 480;
new LwjglApplication(new CanyonBunnyMain(), config);
}
}
Assets.java
package com.packtub.libgdx.canyonbunny.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.assets.AssetErrorListener;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.Disposable;
import com.packtub.libgdx.canyonbunny.util.Constants;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
public class Assets implements Disposable, AssetErrorListener{
public static final String TAG = Assets.class.getName();
public static final Assets instance = new Assets();
private AssetManager assetManager;
//singleton: previene de inicializaciones desde otras clases
private Assets () {}
public AssetBunny bunny;
public AssetRock rock;
public AssetGoldCoin goldCoin;
public AssetFeather feather;
public AssetLevelDecoration levelDecoration;
public void init (AssetManager assetManager){
this.assetManager = assetManager;
//Se establece el asset manager que maneja los errores
assetManager.setErrorListener(this);
//Carga las texturas atlas
assetManager.load(Constants.TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
//Se inicia a cargar los assets y se espera que termine
assetManager.finishLoading();
Gdx.app.debug(TAG, "# de assets cargados: "
+ assetManager.getAssetNames().size);
for (String a : assetManager.getAssetNames()) Gdx.app.debug(TAG, "asset: " + a);
TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS_OBJECTS);
//activa la opcion "texture filtering" para una dibujado mas suave de los pixeles
for (Texture t : atlas.getTextures()) t.setFilter(TextureFilter.Linear, TextureFilter.Linear);
//Crea los objetos del juego
bunny = new AssetBunny(atlas);
rock = new AssetRock(atlas);
goldCoin = new AssetGoldCoin(atlas);
feather = new AssetFeather(atlas);
levelDecoration = new AssetLevelDecoration(atlas);
}
@Override
public void dispose(){
assetManager.dispose();
}
@Override
public void error(AssetDescriptor asset, Throwable throwable) {
Gdx.app.error(TAG, "No se pudo cargar el asset '" + asset + "'", (Exception)throwable);
}
//public void error(String filename, Class type, Throwable throwable){
//Gdx.app.error(TAG, "No se pudo cargar el asset '" + filename + "'", (Exception)throwable);
//}
public class AssetBunny {
public final AtlasRegion head;
public AssetBunny (TextureAtlas atlas){
head = atlas.findRegion("bunny_head");
}
}
public class AssetRock {
public final AtlasRegion edge;
public final AtlasRegion middle;
public AssetRock(TextureAtlas atlas){
edge = atlas.findRegion("rock_edge");
middle = atlas.findRegion("rock_middle");
}
}
public class AssetGoldCoin {
public final AtlasRegion goldCoin;
public AssetGoldCoin(TextureAtlas atlas){
goldCoin = atlas.findRegion("item_gold_coin");
}
}
public class AssetFeather{
public final AtlasRegion feather;
public AssetFeather(TextureAtlas atlas){
feather = atlas.findRegion("item_feather");
}
}
public class AssetLevelDecoration{
public final AtlasRegion cloud01;
public final AtlasRegion cloud02;
public final AtlasRegion cloud03;
public final AtlasRegion mountainLeft;
public final AtlasRegion mountainRight;
public final AtlasRegion waterOverlay;
public AssetLevelDecoration(TextureAtlas atlas){
cloud01 = atlas.findRegion("cloud01");
cloud02 = atlas.findRegion("cloud02");
cloud03 = atlas.findRegion("cloud03");
mountainLeft = atlas.findRegion("mountain_left");
mountainRight = atlas.findRegion("mountain_right");
waterOverlay = atlas.findRegion("water_overlay");
}
}
}
控制台
影像包装..........写入1024x1024:..Canyonbunny-android\assets\images\canyonbunny.pack.png com.packtub.libgdx.canyonbunny.game.assets:No se pudo cargar el asset'images/canyonbunny.pack,com.badlogic.gdx.graphics.g2d.textureAtlas'com.badlogic.gdx.utils.gdxruntimeException:文件未找到:images\canyonbunny.pack(内部)在las.java:103)在com.badlogic.gdx.assets.loaders.textureAtlasLoader.getDependencies(textureAtlasLoader.java:58)在com.badlogic.gdx.assets.loaders.textureAtlasLoader.java:34)在com.badlogic.gdx.assets.assets.assetLoader.handlesyncloader(assetLoadingTask.java:98)在manager.java:466)在com.badlogic.gdx.assets.assetmanager.update(assetmanager.java:354)在com.badlogic.gdx.assets.assetma在com.packtub.libgdx.canyonbunny.game.assets.init(assets.java:35)在com.packtub.libgdx.canyonbunny.canyonbunnymain.create(canyonbunnymain.java:25)在com.badlogic.gdx.backends.lwjglapplication.mainloop(lwjglapplication.java:137)在OS:0线程“LWJGL Application”com.badlogic.gdx.utils.gdxruntimeException:Asset not Loaded:images/canyonbunny.pack at com.badlogic.gdx.assets.assetmanager.get(assetmanager.java:110)at com.packtub.libgdx.canyonbunny.game.assets.init(assets.java:40)at gdx.backends.lwjgl.lwjglapplication$1.run(Lwjglapplication.java:114)
TexturePacker自动放置由settings.atlasExtension(“.atlas”)定义的扩展名。
更改此设置或将constants.texture_atlas_objects变量的值更改为“canyonbunny.pack.atlas”。
如果我创建一个.png 1024 x 1024的纹理,并在中间画一个124 x 124的圆,它的周围将是空的,它使用的RAM是否与我在124x124空间上画一个124 x 124的圆相同?
我目前正在开发一个使用libgdx和java的游戏。我想在我的游戏的一些功能上运行一些JUnit测试,但是我在加载我的资产时遇到了困难。我试图实现Mockito,这样我就可以进行无头JUnit测试,看看这是否有助于解决问题,但这并没有帮助。这里是我试图加载资产的测试类(资产正在第17行加载) 以下是我尝试运行的每个测试的错误消息: 搜索到的文件肯定位于指定的位置,我还将资产文件夹设置为该模块的资源
我可以从flutter应用程序的assets/Images目录加载图像,但当从flutter包的assets/Images目录加载相同的图像时,我会得到以下错误:
创建Laravel 5包时,如何加载CSS/JS文件等资产?我的工作包目前有控制器和视图,但是所有的CSS都放在每个视图的标题中,这不好。 编辑:谢谢你的回答,但也许我说得不太清楚。我的问题是关于Laravel包,而不是Laravel应用程序。在这种情况下,我使用服务提供商加载视图 上面的一行放在方法中。
我希望你能帮我找到错误。干杯,Joshflux 编辑:我很确定,它必须做一些事情与窗口的大小。如果我将窗口的高度从800调整为200,那么左角的人看起来是一样的,但是中间的人要小得多。但还是不知道怎么解决...
我已确保bundler和模拟器正在运行。 如果我用这封信 它可能工作,但当我在模拟器中按rr时,刷新不会发生。我还尝试了abd的反转。对我来说什么都不起作用。 单击此处查看错误屏幕。