nek*_*une 4 java user-interface libgdx
我需要在LibGDX中隐藏标签或图像temporarilly,所以我可以让按钮的一部分是图像或文本,具体取决于传递的值,我试过这个:
public void SetScore(int score)
{
if(score<0)
{
highScore.setWidth(0);
lockImage.setWidth(50);
}
else
{
highScore.setText(Integer.toString(score));
highScore.validate();
lockImage.setWidth(0);
}
}
Run Code Online (Sandbox Code Playgroud)
它完全失败了,有谁知道怎么做?
假设它们是标准的Scene2d小部件,当你想看到它们时,只需使用setVisible(true),否则使用setVisible(false).
沿着这些方向......
public void SetScore(int score)
{
if(score<0)
{
highScore.setVisible(false);
lockImage.setVisible(true);
}
else
{
highScore.setVisible(true);
highScore.setText(Integer.toString(score));
highScore.validate();
lockImage.setVisible(false);
}
}
Run Code Online (Sandbox Code Playgroud)
如果它们占据屏幕上的相同空间,那么您可能需要考虑将它们放在堆栈上.
| 归档时间: |
|
| 查看次数: |
2634 次 |
| 最近记录: |