我试图了解如何在LibGDX中使用ProgressBar.
我创建了酒吧,但我不知道如何让它成功.我想复制旋钮,以便在60秒内填充条形图(背景线).我知道如何管理时间,但ProgressBar类中没有方法用旋钮填充栏.至少,我还没有看到它(或者我不明白怎么样).这是我的代码:
ProgressBar的代码:
skin = new Skin();
Pixmap pixmap = new Pixmap(10, 10, Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.fill();
skin.add("white", new Texture(pixmap));
textureBar = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("barGreen_horizontalMid.png"))));
barStyle = new ProgressBarStyle(skin.newDrawable("white", Color.DARK_GRAY), textureBar);
bar = new ProgressBar(0, 10, 0.5f, false, barStyle);
bar.setPosition(10, 10);
bar.setSize(290, bar.getPrefHeight());
bar.setAnimateDuration(2);
stage.addActor(bar);
Run Code Online (Sandbox Code Playgroud)
我知道我可以用这个方法移动旋钮setValue(float).但我想要的是用旋钮的纹理填充条形.这是一个酒吧的截图和旋钮.

任何人都可以帮我理解这个吗?提前致谢.
我在尝试调试下一个代码时发现了一个问题:
package course.examples.theanswer;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class TheAnswer extends Activity {
public static final int[] answers = { 42, -10, 0, 100, 1000 };
public static final int answer = 42;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.answer_layout);
TextView answerView = (TextView) findViewById(R.id.answer_view);
int val = findAnswer();
String output = (val == answer) ? "42" : "We may never know";
answerView.setText("The answer to life, the universe and everything is:\n\n"
+ output);
}
private int findAnswer() …Run Code Online (Sandbox Code Playgroud)