2013-10-09 2 views
0

아래 코드에서는 플레이어에 두 개의 텍스처를 사용하고 있습니다. 그것의 정상적인 애니메이션이고 점프 애니메이션을위한 또 다른 애니메이션입니다. 당시에 다음 코드로 실행하는 동안 점프하는 프레임 중 일부만이 전부가 아닌 실행 중입니다.터치 패드를 사용하여 XNA에서 플레이어 점프

public void draw(Object sender,GameTimerEventArgs e) 
{ 
     jumpframe++; 

     if (jumpframe > 32) 
     { 
      jumpframe = 0; 
     } 

     TouchPanel.EnabledGestures = GestureType.Tap; 
     TouchCollection touches = TouchPanel.GetState(); 
     if (touches.Count >0) 
     { 
      touch = true; 
      jump(); 
      System.Diagnostics.Debug.WriteLine("touch"); 
     } 
     else if (touches.Count == 0) 
     { 
      playerr(); 
      System.Diagnostics.Debug.WriteLine(currentframe); 
      touch = false; 
     } 
     spriteBatch.Draw(Texture.player[currentframe], Texture.position, Color.White); 
     spriteBatch.Draw(Texture.jumpplayer[jumpframe], Texture.jumpposition, Color.White); 

     currentframe++; 
     if (currentframe > 24) 
     { 
      currentframe = 0; 
     } 

     System.Diagnostics.Debug.WriteLine(jumpframe); 
     spriteBatch.End(); 
     // TODO: Add your drawing code here 
    } 

    public void jump() 
    { 
      Texture.jumpposition.X = 10; 
      Texture.jumpposition.Y = 243; 
      Texture.position.X = -200; 
      Texture.position.Y = 243; 
    } 

    public void playerr() 
    { 
     Texture.position.X = 10; 
     Texture.position.Y = 243; 
     Texture.jumpposition.X = -400; 
     Texture.jumpposition.Y = 243; 
    } 

}

답변

1

jumpframe이 증가하는 경우와 Texture.jumpplayer[jumpframe]가 제대로 스캔 나는 당신의 문제가 Texture.jumpposition 정의라고 생각합니다.

그냥 제안 : 이 아닌 Update 메서드의 터치를 감지하면 해당 메서드는 드로잉 명령에만 사용해야합니다.

관련 문제