私はActorクラスを継承するオブジェクトを作成しようとしています。ステージのdraw()メソッドを呼び出すと、追加したボタンだけが描画されます。ここで私のコードは、多分誰かが私を助けることができる?私の画面クラスの俳優を伸ばしてステージ上に描く方法は? Libgdx
コード(私は必要なすべてのメソッドをオーバーライドして、私はすべての必要なクラスをインポートすることをしていたと仮定): パブリッククラスPlayScreenは{
SpriteBatch batch;
Game game;
Table table;
Skin skin;
Stage stage;
BitmapFont font;
TextButton button;
TextDisplay display;
public PlayScreen(MyGdxGame game, SpriteBatch batch){
this.game = game;
this.batch = batch;
//instantiating Stage, Table, BitmapFont, and Skin objects.
font = new BitmapFont(Gdx.files.internal("MyTruefont.fnt"));
table = new Table();
stage = new Stage();
skin = new Skin(Gdx.files.internal("Test.json"));
button = new TextButton("Start!", skin, "default");
display = new TextDisplay(font, this);
//Setting table properties
table.setWidth(stage.getWidth());
table.align(Align.center|Align.top);
table.setPosition(0, Gdx.graphics.getHeight());
table.padTop(30);
//Adding actors to table
table.add(button).padBottom(50);
table.add(display);
//Adding table to stage and setting stage as the input processor
stage.addActor(table);
Gdx.input.setInputProcessor(stage);
}
@Override
public void show() {
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
stage.draw();
batch.end();
}
を画面を実装し、ここに俳優を拡張マイTextdisplayクラスです(ここでも他のすべてのメソッドをオーバーライドされており、必要なすべてのクラスがインポートされていると仮定):
public class TextDisplay extends Actor implements Drawable {
Texture texture;
BitmapFont font;
String str;
public TextDisplay(BitmapFont font, Screen screen){
this.font = font;
texture = new Texture(Gdx.files.internal("TextArea.png"));
str = "";
setLeftWidth(texture.getWidth());
setRightWidth(texture.getWidth());
setBottomHeight(texture.getHeight());
setTopHeight(texture.getHeight());
}
@Override
public void draw(Batch batch, float x, float y, float width, float height) {
batch.draw(texture, x, y);
}
よろしくお願い致します。私はそれが問題を解決するかどうかを見るためにdrawableを実装しました。私はそれを取り除くことができると思う。私はまだ私の俳優を表すと思われるイメージを描くことができますか?または何かが不足していますか? –
また、Labelクラスは私がしたいことをしません。 –
'draw'メソッドで必要なものを描画することができます。 – Tenfour04