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:
grazie mille in anticipo!
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"); }
}
}
}