Libgdx / Scene2D缩放不起作用

时间:2016-05-05 10:01:21

标签: java graphics libgdx scale scene2d

我正在开发一个小duengon爬虫,我想尝试使用Scene2D实现一个健康栏。但是有一个问题......当我尝试将进度条的大小设置为永远相同的大小时,如果我这样做无关紧要:

healthBar.setWidth(1f);
healthBar.setHeight(0.25f);

or

healthBar.setWidth(100);
healthBar.setHeight(25);

我做错了什么?继承人我是如何创造舞台的^^

camera = new OrthographicCamera(0,0);
camera.setToOrtho(false,Gdx.graphics.getWidth()/Box2dVars.UNIT,Gdx.graphics.getHeight()/Box2dVars.UNIT);
camera.zoom = (float) 0.75;

port = new ExtendViewport(camera.viewportWidth, camera.viewportHeight, camera);

stage = new Stage(port);

我还会在渲染方法中的每个刻度上绘制并绘制舞台。以下是我如何创建ProgressBar:

skin = new Skin(Gdx.files.internal("Scene2D-Skins/uiskin.json"));

healthBar = new ProgressBar(0, 100, 0.5f, false, skin, "default");

healthBar.setWidth(1f);
healthBar.setHeight(0.25f);
healthBar.setPosition(this.getPosition().x, this.getPosition().y);

this.gameScreen.stage.addActor(healthBar);
你看错了吗?我忘记了什么? :/我会很高兴得到一些帮助!

0 个答案:

没有答案