所以,我有一个游戏画面,我设置为800x480,在该屏幕的顶部,我正在尝试创建一个包含一些信息的表格。我将表格边界设置为x = 0,y = 380,width = 800,height = 100,当屏幕呈现时,表格显示在屏幕顶部,就像我想要的那样。但是,在该表下面,我想渲染我添加到舞台上的其他Actors。问题是,它们不是渲染。如果我注释掉我将表格添加到舞台的行,那么所有内容都会很好 - 只有当我添加表格时才会出现问题,即使非表格Actors没有与表格重叠屏幕坐标。出于这个问题的目的,我删除了除了名为“Field”之外的所有Actors,它是一个坐标为x = 0,y = 0,width = 500,height = 300的游戏板。
为什么包含表混淆了我的其他Actors的渲染?
这是我的代码(第一个GameScreen,然后是Field):
public GameScreen(MyGame game) {
// TODO Auto-generated constructor stub
this.game = game;
log = "Starting game";
plyscore = 0;
oppscore = 0;
stage = new Stage(new StretchViewport(800,480));
gameskin = new Skin(Gdx.files.internal("uiskin.json"));
gametable = new Table();
background = new TextureRegionDrawable(new TextureRegion(AssetLoader.background));
field = new Field();
score = new Label(plyscore+" - "+oppscore, gameskin);
logarea = new TextArea(log, gameskin);
logarea.setPrefRows(3);
logscroll = new ScrollPane(logarea, gameskin);
logscroll.setForceScroll(false, true);
logscroll.setFlickScroll(false);
gametable.setBounds(0, 380, 800, 100);
gametable.add(score).width(390);
gametable.add(logscroll).width(390).row();
stage.addActor(gametable);
stage.addActor(field);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.0f, 0.5f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
}
public class Field extends Actor {
public Field() {
setBounds(getX(), getY(), AssetLoader.field.getRegionWidth(),
AssetLoader.field.getRegionHeight());
}
@Override
public void draw(Batch batch, float alpha){
batch.draw(AssetLoader.field,this.getX(),getY());
}
}