为什么我的手机没有在libgdx中加载表格?

时间:2014-02-27 03:40:54

标签: android libgdx

出于某种原因,我的Android手机即使我被绘制也不会加载表格。它显示在桌面版本上,但不在Android版本上。您可以在if语句的render()方法中看到我添加它。它在我的桌面上完美加载。这只显示我用于表的代码。桌面版和手机版具有相同的相机尺寸。除了这张桌子外,其他所有内容都出现在我的手机上。

  public class game implements Screen {


    public void render(float delta) {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        tManager.update(delta);

        backBatch.begin();
        splash.draw(backBatch);
        backBatch.end();

        stage.act(delta);
        stage.draw();

        world.step(TIMESTEP, VITERATIONS, PITERATIONS);

        table2 = new Table(skin);
        table2.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        int numContacts = world.getContactCount();
        if (numContacts > 0) {
                table2.add(heading3).spaceBottom(35).row();
                table2.add(replayButton).spaceBottom(15).row();
                table2.add(menuButton);
                movement.x = -sSpeed;
                movement.y = 10;
                movement.rotate(720);
                stage.addActor(table2);
                Gdx.input.setInputProcessor(stage);
        }

        debugRenderer.render(world, camera.combined);
    }

    public void resize(int width, int height) {
        camera.viewportWidth = 450;
        camera.viewportHeight = 250;
        camera.update();
        stage.setViewport(450, 250, true);
        stage.getCamera().translate(-stage.getGutterWidth(), -stage.getGutterHeight(), 0);
        if (table != null){
            table.setSize(450, 250);
        }

    }

    @Override
    public void show() 
    {
        stage = new Stage();

        world = new World(new Vector2(0, 0), true);
        debugRenderer = new Box2DDebugRenderer();

        camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        //replay button
        replayButton = new TextButton("REPLAY", skin);
        replayButton.addListener(new ClickListener() {
            public void clicked(InputEvent event, float x, float y)
            {
                ((Game) Gdx.app.getApplicationListener()).setScreen(new game());
            }
        });
        replayButton.pad(15);

        //main menu button
        menuButton = new TextButton("MAIN MENU", skin);
        menuButton.addListener(new ClickListener() {
            public void clicked(InputEvent event, float x, float y)
            {
                ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
            }
        });
        menuButton.pad(10);

        //game over
        heading3 = new Label("game over", skin);
        heading3.setFontScale(2);
    }

        private void createCollisionListener() {

            //collisions in world
            world.setContactListener(new ContactListener() {

                public void beginContact(Contact contact) {
                }

                public void endContact(Contact contact) {
                }

                public void preSolve(Contact contact, Manifold oldManifold) {
                }

                public void postSolve(Contact contact, ContactImpulse impulse) {
                }
            });
    }

0 个答案:

没有答案