Biorę się powoli za tworzenie platformówki w XNA. Zrobiłem animacje ruchu w lewo i prawo i ataku także w obie strony, zapisane w png pojedyncze klatki.
Jak stworzyć aby podczas poruszania bohater był animowany?
Moja patologiczna metoda:
[to w Draw] Ruch(podobnie w lewo)
if (Keyboard.GetState().IsKeyDown(Keys.Right))
{
PlayerRectangle.X += 3;
kierunek = 1;
progress += 1;
if (progress > 24)
{
progress = 1;
}
}
[to w Draw] Zmiana klatek:
if (kierunek == 1)
{
if (progress == 1)
{
PlayerTexture = Content.Load<Texture2D>("0001");
}
if (progress == 2)
{
PlayerTexture = Content.Load<Texture2D>("0002");
}
if (progress == 3)
{
PlayerTexture = Content.Load<Texture2D>("0003");
}
if (progress == 4)
{
PlayerTexture = Content.Load<Texture2D>("0004");
}
if (progress == 5)
{
PlayerTexture = Content.Load<Texture2D>("0005");
}
if (progress == 6)
{
PlayerTexture = Content.Load<Texture2D>("0006");
}
if (progress == 7)
{
PlayerTexture = Content.Load<Texture2D>("0007");
}
if (progress == 8)
{
PlayerTexture = Content.Load<Texture2D>("0008");
}
if (progress == 9)
{
PlayerTexture = Content.Load<Texture2D>("0009");
}
if (progress == 10)
{
PlayerTexture = Content.Load<Texture2D>("0010");
}
if (progress == 11)
{
PlayerTexture = Content.Load<Texture2D>("0011");
}
if (progress == 12)
{
PlayerTexture = Content.Load<Texture2D>("0012");
}
if (progress == 13)
{
PlayerTexture = Content.Load<Texture2D>("0014");
}
if (progress == 14)
{
PlayerTexture = Content.Load<Texture2D>("0014");
}
if (progress == 15)
{
PlayerTexture = Content.Load<Texture2D>("0015");
}
if (progress == 16)
{
PlayerTexture = Content.Load<Texture2D>("0016");
}
if (progress == 17)
{
PlayerTexture = Content.Load<Texture2D>("0017");
}
if (progress == 18)
{
PlayerTexture = Content.Load<Texture2D>("0018");
}
if (progress == 19)
{
PlayerTexture = Content.Load<Texture2D>("0019");
}
if (progress == 20)
{
PlayerTexture = Content.Load<Texture2D>("0020");
}
if (progress == 21)
{
PlayerTexture = Content.Load<Texture2D>("0021");
}
if (progress == 22)
{
PlayerTexture = Content.Load<Texture2D>("0022");
}
if (progress == 23)
{
PlayerTexture = Content.Load<Texture2D>("0023");
}
if (progress == 24)
{
PlayerTexture = Content.Load<Texture2D>("0024");
}
}
Jedna z animacji w gifie:

I przy okazji, jak przesuwać kamerę?