在过去的几天里,我一直将我的游戏(Apopalypse)移植到Android移动平台.我已经在Google上快速搜索了精灵触摸检测,但没有找到任何有用的信息.一旦触摸,每个气球都会弹出,我只需要检测它是否被触摸过.这是我的气球产卵代码:
渲染(x,y,宽度和高度随机化):
public void render() {
y += 2;
balloon.setX(x);
balloon.setY(y);
balloon.setSize(width, height);
batch.begin();
balloon.draw(batch);
batch.end();
}
Run Code Online (Sandbox Code Playgroud)
在主要游戏类中产卵:
addBalloon(new Balloon());
public static void addBalloon(Balloon b) {
balloons.add(b);
}
Run Code Online (Sandbox Code Playgroud)