致命信号11(SIGSEGV),代码1,故障地址0x0(libGDX)

时间:2016-03-01 19:24:55

标签: android libgdx

当我尝试进入播放屏幕时,我在三星Galaxy S6 Edge上收到致命信号11。在桌面模拟器上它工作正常,我可以进入playcreen类。我还测试了Nexus 6,它甚至在那里工作。我的手机出了什么问题?

当我尝试调试应用程序崩溃时,我正在阅读此行:

app.getApplicationListener().render();

PlayScreen类:

public class PlayScreen2 implements Screen {
    private TextureAtlas atlas;


    private OrthographicCamera gamecam;
    private Viewport gamePort;
    private Hud2 hud;

    private TmxMapLoader maploader;
    private TiledMap map;
    private OrthogonalTiledMapRenderer renderer;

    private World world;
    public Box2DDebugRenderer b2dr;
    public static Runner player;
    private float dt;
    private boolean keyPressed = false;
    private boolean keyPressed2 = false;






    public PlayScreen2(){



        atlas = new TextureAtlas("Runner_And_Enemies.pack");

        gamecam = new OrthographicCamera();
        gamePort = new FitViewport(RunningGame.V_WIDTH / RunningGame.PPM, RunningGame.V_HEIGHT / RunningGame.PPM, gamecam);
        hud = new Hud2(Globals.game.batch);


        maploader = new TmxMapLoader();
        map = maploader.load("level2.tmx");
        renderer = new OrthogonalTiledMapRenderer(map, 1 / RunningGame.PPM);
        gamecam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2 , 0);

        world = new World(new Vector2(0, -10), true);
        b2dr = new Box2DDebugRenderer();

        new B2WorldCreator(world, map);
        player = new Runner(world, this);




    }

    public TextureAtlas getAtlas(){
        return atlas;

    }

    @Override
    public void show() {

    }


    public void handleInput(float dt){

        if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) {
            if (!keyPressed) {
                keyPressed = true;
                if (player.b2body.getLinearVelocity().x <= 4) {
                    player.b2body.applyLinearImpulse(new Vector2(0.3f, 0), player.b2body.getWorldCenter(), true);

                }
                Hud2.addscore(1);
            }
        } else {
            keyPressed = false;
        }



        if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
            if (!keyPressed2) {
                keyPressed2 = true;
                if (player.b2body.getLinearVelocity().y <= 4.0f) {
                    player.b2body.applyLinearImpulse(new Vector2(0, 3.0f), player.b2body.getWorldCenter(), true);

                }

            }
        } else {
            keyPressed2 = false;
        }



        if (Gdx.input.isKeyPressed(Input.Keys.LEFT) && player.b2body.getLinearVelocity().x >= -2)
            player.b2body.applyLinearImpulse(new Vector2(-5.2f, 0), player.b2body.getWorldCenter(), true);



    }

    public void update(float dt){
        handleInput(dt);

        world.step(1 / 60f, 6, 2);



        player.update(dt);
        hud.update(dt);
        gamecam.position.x = player.b2body.getPosition().x;

        gamecam.update();
        renderer.setView(gamecam);

    }

    @Override
    public void render(float delta) {
        update(delta);


        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        renderer.render();

        b2dr.render(world, gamecam.combined);

        Globals.game.batch.setProjectionMatrix(gamecam.combined);
        Globals.game.batch.begin();
        player.draw(Globals.game.batch);
        Globals.game.batch.end();

        Globals.game.batch.setProjectionMatrix(hud.stage.getCamera().combined);
        hud.stage.draw();



    }

    @Override
    public void resize(int width, int height) {
        gamePort.update(width, height);



    }

    @Override
    public void pause() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void hide() {

    }

    @Override
    public void dispose() {
        map.dispose();
        renderer.dispose();
        world.dispose();
        b2dr.dispose();
        hud.dispose();

    }

}

0 个答案:

没有答案