Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LIBGDX输入已打开()_Java_Android_Eclipse_Libgdx - Fatal编程技术网

Java LIBGDX输入已打开()

Java LIBGDX输入已打开(),java,android,eclipse,libgdx,Java,Android,Eclipse,Libgdx,有人能告诉我为什么我的球员不动吗。它开始移动,直到player.dat被保存,然后它只是轻轻一推,回到原来的位置 public class Player implements Serializable, InputProcessor{ private static final long serialVersionUID = 1L; Vector2 position, touchPosition; String textureLoc; public Player(Vector2 positio

有人能告诉我为什么我的球员不动吗。它开始移动,直到player.dat被保存,然后它只是轻轻一推,回到原来的位置

public class Player implements Serializable, InputProcessor{

private static final long serialVersionUID = 1L;
Vector2 position, touchPosition;
String textureLoc;

public Player(Vector2 position, String textureLoc){
    this.position = position;
    }

public void update(){

    position = new Vector2(0,0);
    Vector2 touchPosition = new Vector2(0,0);


    if (Gdx.input.isTouched()){
        touchPosition.set(Gdx.input.getX(), Gdx.input.getY());

    }
    if(touchPosition.x > position.x){
        position.x += 2f;}

     if (touchPosition.x < position.x){
            position.x -= 2f;}

    if(touchPosition.y > position.y){
        position.y += 2f;}

     if (touchPosition.y < position.y){
            position.y -= 2f; 
    }

}
public类播放器实现可序列化的输入处理器{
私有静态最终长serialVersionUID=1L;
矢量2位置,触摸位置;
线纹织物;
公共播放器(矢量2位置,字符串纹理){
这个位置=位置;
}
公共无效更新(){
位置=新矢量2(0,0);
Vector2 touchPosition=新Vector2(0,0);
if(Gdx.input.isTouched()){
set(Gdx.input.getX(),Gdx.input.getY());
}
if(touchPosition.x>position.x){
位置x+=2f;}
if(touchPosition.xposition.y){
位置y+=2f;}
if(touchPosition.y

这是玩家级的。请帮助。我已经被难倒两天了!

将此移到构造器:

position = new Vector2(0,0);
如果
update
中有这一行,则每次都会重置
位置

附言:你也可能会在你的私人和全球接触职位上遇到麻烦