【发布时间】:2014-07-09 18:43:12
【问题描述】:
所以,我正在制作一个飞扬的鸟克隆。问题是我是使用 java 和 libgdx 编程的新手,我想请你帮忙。我想在特定区域(只是一个简单的矩形)上进行触摸检测,而不是在整个屏幕上单击。
这是我当前输入处理程序类的代码:
public class InputHandler implements InputProcessor {
private Bird myBird;
private GameWorld myWorld;
// Ask for a reference to the Bird when InputHandler is created.
public InputHandler(GameWorld myWorld) {
// myBird now represents the gameWorld's bird.
this.myWorld = myWorld;
myBird = myWorld.getBird(); }
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (myWorld.isReady()) {
myWorld.start();
}
myBird.onClick();
if (myWorld.isGameOver() || myWorld.isHighScore()) {
// Reset all variables, go to GameState.READ
myWorld.restart();
}
return true;
}
@Override
public boolean keyDown(int keycode) {
return false;
}
@Override
public boolean keyUp(int keycode) {
return false;
}
@Override
public boolean keyTyped(char character) {
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
return false;
}
@Override
public boolean scrolled(int amount) {
return false;
}
}
【问题讨论】:
-
您最好按照教程进行操作,而不是指望有人填写点点滴滴。一切顺利。
标签: java android libgdx flappy-bird-clone