Platformówka XNA 3618 1

O temacie

Autor Leinnan

Zaczęty 27.12.2012 roku

Wyświetleń 3618

Odpowiedzi 1

Leinnan

Leinnan

Administrator
torsonic polarity syndrome
posty2651
Propsy3600
ProfesjaProgramista
  • Administrator
  • torsonic polarity syndrome

Leinnan
Administrator

Platformówka XNA
2012-12-28, 00:00(Ostatnia zmiana: 2012-12-28, 00:05)
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ę?:D
 
Mit der Dummheit kämpfen die Götter selbst vergebens

steam | slavic castles |  last.fm | moddb.com | Stary, najlepszy lider Sclavinii

RafalBudzis

RafalBudzis

Użytkownicy
posty1967
Propsy808
ProfesjaSkrypter
  • Użytkownicy

RafalBudzis

Platformówka XNA
#1 2012-12-28, 10:52(Ostatnia zmiana: 2012-12-28, 11:02)

[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");

            }
            .........



zamiast tego wystarczy
        if (kierunek == 1)
        {
PlayerTexture = Content.Load<Texture2D>(progress.ToString());
}

tyle że tekstury musisz nazwać bez tych zer :P

Z resztą nie wiem czy to taki super sposób żeby ładować tekstury z plików ciągle załaduj tekstury do tablicy

for int i = 0;i<=24;i++){

PlayerTexture[i] = Content.Load<Texture2D>(i.ToString());

}

 w wyświetlaniu daj

Draw(PlayerTexture[progress],rec,Color.White);

p.s. animacja jest zajebista


0 użytkowników i 1 Gość przegląda ten wątek.
0 użytkowników
Do góry