我有一个实现的 Screen 类GestureListener
,但它不提供PanStop
方法(在 LibGdx JavaDocs 和 Wiki 中提到)
是否已删除此方法(并且文档已过时),还是我遗漏了什么?
如果是前者,那么如何检测和处理修饰或平移停止?
谢谢。
编辑:添加实施....
package com.me.mygdxgame;
import com.badlogic.gdx.Gdx;
import java.util.Random;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
import com.badlogic.gdx.utils.Array;
import com.me.mygdxgame.actors.ActorJ;
public class JGameScreen implements Screen, GestureListener {
final MyGdxGame game;
private Stage stage;
private GameGrid gameGrid;
// Constructor & Init Screen
//
public JGameScreen(final MyGdxGame gam) {
game = gam;
stage = new Stage();
stage.setViewport(600, 600, true);
gameGrid = new GameGrid(stage, 10, 10);
}
// GestureListener Events
//
@Override
public void show() {
// TODO Auto-generated method stub
Gdx.input.setInputProcessor(new GestureDetector(this));
}
@Override
public boolean touchDown(float x, float y, int pointer, int button) {
// TODO Auto-generated method stub
//chain = gameGrid.getChain();
return false;
}
@Override
public boolean pan(float x, float y, float deltaX, float deltaY) {
// TODO Auto-generated method stub
vector2 = stage.screenToStageCoordinates(vector2.set(x,y));
gameGrid.get(25).setPosition(vector2.x, vector2.y);
return true;
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public void hide() {
// TODO Auto-generated method stub
Gdx.input.setInputProcessor(null);
}
@Override
public void render(float delta) {
// TODO Auto-generated method stub
Gdx.gl.glClearColor( 0.9f, .04f, 0.2f, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
stage.act(delta);
stage.draw();
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
stage.setViewport(game.WIDTH, game.HEIGHT, true);
stage.getCamera().translate(-50, -50, 0);
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public boolean tap(float x, float y, int count, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean longPress(float x, float y) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean zoom(float initialDistance, float distance) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
Vector2 pointer1, Vector2 pointer2) {
// TODO Auto-generated method stub
return false;
}
}