C# Problema GIF

Stato
Discussione chiusa ad ulteriori risposte.

Flynns82

Utente Electrum
14 Gennaio 2013
265
42
25
151
Ciao a tutti, ho un problema, sto cercando di fare un giochino semplice e ho un'omino che devo muovere(con wasd) per l'omino ho disegnato 4 frame, 1 per ogni direzione e poi unendo le immagini ho creato la gif,solo che quando mi muovo la gif non parte, o mi fa vedere solo il primo dei 4 frame della gif, non riesco a capire perchè, il codice è questo:
Codice:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;

namespace Chuck
{
  public partial class Level1 : Form
  {
  bool destra, sinistra,su, giu;
  public Level1()
  {
  InitializeComponent();
  Player.Image = Image.FromFile(@"Images\\Personaggio\\1 - Front\\1-1.png");
  }

  private void timer1_Tick(object sender, EventArgs e)
  {
  //MOVIMENTI E IMPOSTAZIONE GIF CON LE GAMBE CHE SI MUOVONO
  if (su == true) { Player.BackgroundImage = new Bitmap(@"Images\\Personaggio\\4 - Behind\\4-x.gif"); Player.Top -= 2; }
  if (sinistra == true) { Player.BackgroundImage = new Bitmap(@"Images\\Personaggio\\2 - Left\\2-x.gif");  Player.Left -= 2; }
  if (giu == true) { Player.BackgroundImage = new Bitmap(@"Images\\Personaggio\\1 - Front\\1-x.gif"); Player.Top += 2; }
  if (destra == true) { Player.BackgroundImage = new Bitmap(@"Images\\Personaggio\\3 - Right\\3-x.gif"); Player.Left += 2; }

  }

  private void Form1_KeyDown(object sender, KeyEventArgs e)
  {
  if (e.KeyCode == Keys.W) { su = true;  }
  if (e.KeyCode == Keys.A) { sinistra = true;  }
  if (e.KeyCode == Keys.S) { giu = true;  }
  if (e.KeyCode == Keys.D) { destra = true;  }
  }

  private void Form1_KeyUp(object sender, KeyEventArgs e)
  {
    //AL RILASCIO DI UNO DEI TASTI, IMPOSTA L'OMINO A GAMBE UNITE
  if (e.KeyCode == Keys.W) { su = false; Player.Image = Image.FromFile(@"Images\\Personaggio\\4 - Behind\\4-1.png"); }
  if (e.KeyCode == Keys.A) { sinistra = false; Player.Image = Image.FromFile(@"Images\\Personaggio\\2 - Left\\2-1.png"); }
  if (e.KeyCode == Keys.S) { giu = false; Player.Image = Image.FromFile(@"Images\\Personaggio\\1 - Front\\1-1.png"); }
  if (e.KeyCode == Keys.D) { destra = false; Player.Image = new Bitmap(@"Images\\Personaggio\\3 - Right\\3-1.png"); }
  }


  }
}
grazie mille in anticipo!
 
Non ti basta usare 4 immagini differebti.?
Se vuoi andare avanti mostri la prima, se vuoi andare a DX mostri quella dell'omino volto verso destra e cosi via..non so se mi sono spiegato

Sent from my LG-D802 using Tapatalk
 
sisi capito :) prima era cosi ma è brutto.. cioè, preferivo che quando andavo in una direzione l'omino camminava, vedere un'immagine che striscia, in un gioco, è troppo brutto :D
 
  • Mi piace
Reazioni: ONE OK ROCK
sisi capito :) prima era cosi ma è brutto.. cioè, preferivo che quando andavo in una direzione l'omino camminava, vedere un'immagine che striscia, in un gioco, è troppo brutto :D
Allora anziché usarne 4 usi 8img.(2 per movimento)

Ad esempio, se vai avanti mostri la prima dove l'omino ha il piede sinistro e il braccio destro avanzati, subito dopo la seconda dove ha il piede destro e braccio sinistro.

Insomma, ti costruisci la tua GIF sul momento

Ps: Ho visto ora il codice e appena solo al PC provo a darci un occhiata

Sent from my LG-D802 using Tapatalk
 
Stato
Discussione chiusa ad ulteriori risposte.