这是让我感到困惑的代码。我可能在这里遗漏了一些东西,但无法弄清楚。
public class TStage extends Stage {
public TStage(float width, float height, boolean stretch) {
super(width, height, stretch);
}
@Override
public Actor hit(float x, float y) {
Gdx.app.debug("HUNT", "in hit of TStage");
return super.hit(x, y);
}
}
public class TActor extends Actor {
@Override
public void draw(SpriteBatch batch, float parentAlpha) {
// draw something here
}
@Override
public Actor hit(float x, float y) {
Gdx.app.debug("HUNT", "in hit of TActor");
return null;
}
}
/* Code to set stage*/
TStage stage = new TStage(Hunt.GAME_WIDTH, Hunt.GAME_HEIGHT, false);
Gdx.input.setInputProcessor(stage);
TActor actor1 = new TActor();
stage.addActor(tactor);
当我触摸屏幕
输出:
in hit of TActor
我所期待的:
in hit of TStage
in hit of TActor
[编辑]
我将以下代码添加到 TStage 类
@Override
public Actor touchDown(int x, int y, int pointer, int button) {
Gdx.app.debug("HUNT", "in touchDown of TStage");
return super.touchDown(x, y, pointer, button);
}
现在输出是:
in touchDown of TStage
in hit of TActor