【发布时间】:2016-06-20 10:23:00
【问题描述】:
我的程序检测到图像与屏幕边缘之间的碰撞,但碰撞后我无法拖动图像。我要进行哪些更改,以便我仍然可以拖动图像并且不让图像超出屏幕边缘?
我制作的 Gif 示例:https://s31.postimg.org/f60hh3z2z/Animation.gif
内部渲染
batch.begin();
batch.draw(texture, spritePosition.x, spritePosition.y);
batch.end();
if (Gdx.input.isTouched() && isNotColliding()) {
camera.unproject(spritePosition.set(Gdx.input.getX() - texture.getWidth() / 2, Gdx.input.getY() + texture.getHeight() / 2, 0));
}
textureBounds.set(spritePosition.x, spritePosition.y, texture.getWidth(), texture.getHeight());
.
private boolean isNotColliding(){
return screenBounds.contains(textureBounds);
}
【问题讨论】:
标签: android libgdx collision-detection