我正试图在libgdx游戏中实现触摸滚动.我有一个宽广的图像,是一个房间的全景.我希望能够滚动图像,以便用户可以在房间周围看到.我有它,所以我可以滚动一定的距离但是当注册新的touchDragged事件时,图像被移回原始位置.
这就是我实现它的方式
public class AttackGame implements ApplicationListener {
AttackInputProcessor inputProcessor;
Texture backgroundTexture;
TextureRegion region;
OrthographicCamera cam;
SpriteBatch batch;
float width;
float height;
float posX;
float posY;
@Override
public void create() {
posX = 0;
posY = 0;
width = Gdx.graphics.getWidth();
height = Gdx.graphics.getHeight();
backgroundTexture = new Texture("data/pancellar.jpg");
region = new TextureRegion(backgroundTexture, 0, 0, width, height);
batch = new SpriteBatch();
}
@Override
public void resize(int width, int height) {
cam = new OrthographicCamera();
cam.setToOrtho(false, width, height);
cam.translate(width / 2, height / …Run Code Online (Sandbox Code Playgroud)