2014-07-16 1 views
0

내 플레이어가 움직이지 않는 이유는 아무에게도 알려주지 못합니다. player.dat가 저장 될 때까지 움직이기 시작했습니다. 그냥 찔러서 원래 위치로 되돌아갑니다.LIBGDX 입력 isTouched()

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; 
    } 

} 

이것은 플레이어 등급입니다. 도와주세요. 나는 2 일 동안 곤란을 겪었다! 생성자에

답변

2

이동이 :

position = new Vector2(0,0); 

당신은 당신의 update 당신이 position를 재설정 할 때마다이 라인이있는 경우.

ps : 나만의 개인 및 전 세계적인 위치에 문제가 발생할 수도 있습니다.