我试图覆盖我的Player类,它扩展了Actor绘制方法,但我收到一个错误说
Player类型的draw(SpriteBatch,float)方法必须覆盖或实现超类型方法
为什么我不能覆盖类中的默认draw方法Actor?这是我在Player类中的代码.
public class Player extends Actor {
@Override
public void draw(SpriteBatch batch, float parentAlpha) {
Gdx.app.log(getName(), "Drawing player");
}
public Player() {
setName("mainPlayer");
playerBounds = new Rectangle(100, 100, 32, 32);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我正在绘制舞台的类中的代码.
public class Mainscreen implements Screen {
// Class TAG
private static final String TAG = "Main Screen";
// Screen Variable(s)
private Awakening g;
private SpriteBatch sprBatch;
private OrthographicCamera gameCamera;
private Player mainPlayer;
// Screen Stage(s)
private sMain sMain;
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我目前正在使用LibGDX创建游戏,目前我正在创建我的标题屏幕.我无法在屏幕上居中显示TextButtons,如果将TextButton的宽度设置为舞台的宽度,我可以让它们居中,但是如果你点击该按钮从左到右的任何地方都可以按下按钮而不是你只需点击按钮本身.
我如何让TextButtons以游戏屏幕为中心并以彼此为中心?我有三个TextButtons(新游戏,继续和退出游戏).
任何帮助将不胜感激,谢谢!
编辑:
这是我的三个按钮的代码.
btnNG = new TextButton("New Game", btnStyle[0]) {
{
setName("New Game");
addListener(new InputListener() {
public boolean touchDown(InputEvent e, float x, float y, int pointer, int button) {
g.debugOut(btnNG.getName(), "touchDown?");
return true;
}
public void touchUp(InputEvent e, float x, float y, int pointer, int button) {
g.debugOut(btnNG.getName(), "touchUp?");
//g.switchScreen(new Mainscreen(g));
}
});
setWidth(sTitle.getWidth());
setPosition(0, (getHeight() * 2.5f));
}
};
btnContinue = new TextButton("Continue", btnStyle[0]) {
{
setName("Continue");
addListener(new InputListener() {
public boolean touchDown(InputEvent e, float x, float …Run Code Online (Sandbox Code Playgroud)