Мне нужна ваша помощь!
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Texture;
public class TriAngle extends Figure implements InputProcessor {
private float w = 800;
private float h = 600;
public TriAngle() {
setTextureRegion(new Texture(Gdx.files.internal("TriAngle.png")));
setBounds(0, 0, w / 4, h / 4);
Gdx.input.setInputProcessor(this);
}
@Override
public boolean keyDown(int i) {
return false;
}
@Override
public boolean keyUp(int i) {
return false;
}
@Override
public boolean keyTyped(char c) {
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
if(screenX>0&&screenX<200) {
this.setPosition(screenX, screenY, 0);
}
return true;
}
@Override
public boolean mouseMoved(int x, int y) {
/* if (x >= 0) {
this.setPosition(x,y);
}*/
return true;
}
@Override
public boolean scrolled(int i) {
return false;
}
}
В методе touchDragged я перемещаю актера, только если щелчок мыши находится в координате x между 0 и 200. Мне нужно иметь возможность перемещать актера нажав на место, где его текущая позиция.