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