我的程序打包了一系列图像,并将它们输出为aste.png和aste.atlas。我的打包代码如下:
public void pack(){
System.out.println("Packing should not be ordinarily called! If you did not have explicit intentions of Packing, please check ImageAtlas constructor.");
Settings settings = new Settings();
settings.maxWidth =
我一直在学习用java和libgdx编写游戏代码。在我尝试过的任何语言中,我最讨厌的部分是级别编辑器(.TMX,平铺)解析。用于libgdx的Github表示,有一个有用的类,我一直在尝试遵循这些说明,但我被卡住了。
基本上,如果我注释掉下面的代码行,应用程序运行良好,但当然没有任何级别元素。当我有这一行代码,它会立即崩溃我的手机,同时加载应用程序:
TiledMap map
public Level(OrthographicCamera camera) {
map = new TmxMapLoader().load("level1.tmx"); /// THIS L
我试图制作一个简单的游戏,在游戏中创建多个瘦平台。我相信所有的设置都是正确的,通过调试,我发现平台的创建是正确的(带有随机偏移)。问题是,只呈现了最后创建的平台,而不是所有这些平台。
我使用一个类来管理平台,其中包含一个内部私有类,该类包含平台信息(position,sprite):
private class Platform{
private Vector2 mVelocity;
private Vector2 mPosition;
private Sprite mTexture;
public Platform(int x, int y, int w,
如果我在从TextureAtlas检索到的Texture上调用sprite.getTexture().dispose();,整个屏幕就会变黑。
public class PlayState extends State {
// The falling objects from the sky
private Array<FallingObject> objects;
private AssetManager assetManager;
private TextureAtlas textureAtlas;
private Sprite backgro
所以我有两个独立的程序,但是我在一个而不是另一个上加载图像有困难。
在第一个,我有一个图像,我加载作为纹理在mainGameScreen.java中,是800x480像素。
Texture img1;
img1= new Texture(Gdx.files.internal("bg1.png"));
而且它完全没有问题
所以第一个问题是,为什么一个负载而另一个负载不加载,即使第一个只是第二个的景观版本。
在我的第二个程序中,我有一个图像是480x800。但是,我在Images.java中加载它。
public class Images{
public static Te
我在游戏开始时使用gdx-freetype加载了truetype字体。加载时间太长,所以我想在另一个线程中加载字体。但是当它完成加载时,字体不能正确地呈现。像这样
但是当我关掉屏幕,它又一次正确地显示出来:
当屏幕一次又一次关闭时,我想知道是什么在切换这个更改,以及我应该如何修复它。
代码:
public class Game extends com.badlogic.gdx.Game {
SpriteBatch batch;
BitmapFont engFont;
AsyncResult<Void> loadResult;
static final int
我在用ApplicationAdapter。当我在create()方法中有下面的代码时,我的fps总是大约14。
for (i in 0..1000) {
stage.addActor(Food(
Food.TEXTURE_PURPLE!!,
100f,
(random.nextInt(MAP_SIZE)).toFloat(),
(random.nextInt(MAP_SI
我有以下枚举文件"DevelopmentCardType":
enum DevelopmentCardType {
KNIGHT (0, new Texture(Gdx.files.internal("knight_card.png")));
VICTORY_POINT (1, new Texture(Gdx.files.internal("victory_point_card.png"))),
private final Texture cardTexture;
private final int type;