0
ゲームのUIで、スコアを書くためにボックスイメージにラベルを付けました。スコアで文字列を作成し、スコアが動的に変化している間に以前のスコアを消去しない-LibGdx
private void drawNoOfCoins() {
Label.LabelStyle style = new Label.LabelStyle();
style.font = game.font2;
Label totalCoinLabel = new Label(coinScoreController.getTotalCoinString(), style);
totalCoinLabel.setPosition(showcoinImage.getWidth()/2,Constants.WORLD_HEIGHT - 2 * totalCoinLabel.getHeight());
stage.addActor(totalCoinLabel);
totalCoinLabel.setBounds(showcoinImage.getX(), showcoinImage.getY(),showcoinImage.getWidth(), showcoinImage.getHeight());
totalCoinLabel.setAlignment(Align.center);
}
private void ShowCoinScoreBox() {
showcoinImage = new Image(showScoreTexture);
showcoinImage.setPosition(Constants.WORLD_WIDTH/42,Constants.WORLD_HEIGHT - (showcoinImage.getHeight() * 1.5f));
stage.addActor(showcoinImage);
}
私は、このメソッドdrawNoOfCoinsを呼び出しています()でレンダリング()とスコアが動的に更新きています。
しかし、スコアが動的に変化するたびに、更新されたスコアが前のスコアの上に表示されます。 この問題はラベルやその他のものが原因ですか? どうすれば解決できますか?
インサイド
あなたは* *ステージにすべてのループを、スコアを追加するべきではありません!ステージのラベルをクラスの初期化中にステージに一度追加してから、スコアラベルへの参照を保持し、必要に応じて更新します。 – munyul