Libgdx - TextureAtlas 停止了我的应用程序

Libgdx - TextureAtlas has stopped my application

我正在从扩展 libgdx class 游戏的主游戏 class 加载资产。在那个 class 的 create() 方法中,我正在调用 Assets.loadAtlas(); 并且这个调用:

public static void loadAtlas() {
    String textureFile = "data/rubenSprite.txt";
            myTextures = new TextureAtlas(Gdx.files.internal(textureFile));

            TextureRegion[] walkRightFrames = new TextureRegion[4];
            for (int i = 0; i < 5; i++) 
            {
                walkRightFrames[i] = myTextures.findRegion("wframe" + (i + 1));
            }
            rubenWalkRight = new Animation(0.2f, walkRightFrames[0], walkRightFrames[1], 
                    walkRightFrames[2], walkRightFrames[3], walkRightFrames[4]);

            TextureRegion[] walkLeftFrames = new TextureRegion[4];
            for (int i = 0; i < 5; i++) 
            {
                walkLeftFrames[i] = new TextureRegion(walkRightFrames[i]);
                walkLeftFrames[i].flip(true,false);

            }
            rubenWalkLeft = new Animation(0.2f, walkLeftFrames[0], walkLeftFrames[1],
                    walkLeftFrames[2], walkLeftFrames[3], walkLeftFrames[4]);

            TextureRegion[] idleRightFrames = new TextureRegion[3];
            for (int i = 0; i < 4; i ++) 
            {
                idleRightFrames[i] = myTextures.findRegion("iframe" + (i + 1));

            }
            rubenIdleRight = new Animation(0.2f, idleRightFrames[0], idleRightFrames[1],
                    idleRightFrames[2], idleRightFrames[3]);

            TextureRegion[] idleLeftFrames = new TextureRegion[3];
            for (int i = 0; i < 4; i++) 
            {
                idleLeftFrames[i] = new TextureRegion(idleRightFrames[i]);
                idleLeftFrames[i].flip(true,false);
            }
            rubenIdleLeft = new Animation(0.2f, idleLeftFrames[0], idleLeftFrames[1], 
                    idleLeftFrames[2], idleLeftFrames[3]);

            TextureRegion[] jumpRightFrames = new TextureRegion[4];
            for (int i = 0; i < 5; i++)
            {
                jumpRightFrames[i] = myTextures.findRegion("jframe" + (i + 1));
            }

            rubenJumpRight = new Animation(0.2f, jumpRightFrames[0], jumpRightFrames[1], 
                    jumpRightFrames[2], jumpRightFrames[3], jumpRightFrames[4]);


            TextureRegion[] jumpLeftFrames = new TextureRegion[4];
            for (int i = 0; i < 5; i++)
            {
                jumpLeftFrames[i] = new TextureRegion(jumpRightFrames[i]);
                jumpLeftFrames[i].flip(true,false);
            }
            rubenJumpLeft = new Animation(0.2f, jumpLeftFrames[0], jumpLeftFrames[1], 
                    jumpLeftFrames[2], jumpLeftFrames[3], jumpLeftFrames[4]);   

            TextureRegion fallRight = new TextureRegion();
            fallRight = myTextures.findRegion("fall");
            rubenFallRight = new Animation(0f, fallRight);

            TextureRegion fallLeft = new TextureRegion(fallRight);      ;
            fallLeft.flip(true,false);
            rubenFallLeft = new Animation(0f, fallLeft);
    }

从我看过的教程来看,这对我来说似乎是正确的。我已经给出了播放器状态,并根据播放器所处的状态在 mainRenderer 中绘制了其中的动画。这段代码看起来也不错:

private void renderRuben () {
        TextureRegion keyFrame;
        switch (world.ruben.getState()) {
        case Ruben.RUBEN_STATE_HIT:
            keyFrame = Assets.bobHit;
            break;
        case Ruben.RUBEN_STATE_WALKING: 
            if (Ruben.facingRight == true) 
            {
                keyFrame = Assets.rubenWalkRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
            }
            else 
            {
                keyFrame = Assets.rubenWalkLeft.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
            }
        case Ruben.RUBEN_STATE_FALL:
            if (Ruben.facingRight == true) {
                keyFrame = Assets.rubenFallRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
                                           }
            else {
                keyFrame = Assets.rubenFallLeft.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
                 }
        case Ruben.RUBEN_STATE_JUMP:  
            if (Ruben.facingRight == true) {
                keyFrame = Assets.rubenJumpRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
                                           }
            else {
                keyFrame = Assets.rubenJumpRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_NONLOOPING);
                break;
                 }
        case Ruben.RUBEN_STATE_IDLE:
        default:
            if (Ruben.facingRight == true) {
            keyFrame = Assets.rubenIdleRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_LOOPING);
            }
            else {
            keyFrame = Assets.rubenIdleRight.getKeyFrame(world.ruben.getStateTime(), Animation.ANIMATION_LOOPING);
            }
    }


        float side = world.ruben.getVelocity().x < 0 ? -1 : 1;
        if (side < 0)
            batch.draw(keyFrame, world.ruben.position.x + 0.5f, world.ruben.position.y - 0.5f, side * Ruben.RUBEN_WIDTH, Ruben.RUBEN_HEIGHT);
        else
            batch.draw(keyFrame, world.ruben.position.x - 0.5f, world.ruben.position.y - 0.5f, side * Ruben.RUBEN_WIDTH, Ruben.RUBEN_HEIGHT);
    }

我使用 TexturePacker GUI 打包了 Atlases,并将 png 和 txt 文件保存到 /assets/data 文件夹中。

整个项目没有错误,在模拟器中打开时就显示'application not responding'。我做错了什么?

游戏创建方法class:

public class GameView extends Game {
    // used by all screens
    public SpriteBatch batcher;
    @Override
    public void create () {
        batcher = new SpriteBatch();
        Settings.load();
        Assets.loadAtlas();
        setScreen(new MainMenuScreen(this));
    }
} 

总的来说,这是与模拟器有关,而不是应用程序,模拟器与 Open GL ES 2.0 不兼容,所以我下载了 GenyMotion,现在它工作正常。

http://www.genymobile.com/en/