![]() |
Resultado Final |
Empecemos:
Ahora mostrado en texto en caso de que no sean legible las imágenes:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Animacion
{
public partial class Form1 : Form
{
int c = 0; //ESTA ES LA VARIABLE DONDE SE ALMACENARÁ CADA FOTOGRAMA
public Form1()
{
InitializeComponent();
}
// AQUÍ SE PROGRAMA LO QUE OCURRIRÁ AL PRESIONAR EL BOTÓN 1 (INICIO)
private void button1_Click(object sender, EventArgs e)
{
timer1.Start(); // EL TIMER COMENZARÁ A DAR SUS PULSOS
}
// AQUÍ SE PROGRAMA LO QUE OCURRIRÁ AL PRESIONAR EL BOTÓN 2 (PARAR)
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop(); // EL TIMER SE DETENDRÁ
}
// TIMER
private void timer1_Tick(object sender, EventArgs e)
{
c++; // AUMENTARÁ EN 1 EL VALOR DE NUESTRA VARIABLE CADA QUE COMIENCE UN PULSO
/* A CONTINUACIÓN ASIGNAMOS LA RUTA DE DONDE EL PROGRAMA COLOCARÁ LAS IMÁGENES EN EL PICTUREBOX
* COMO PODEMOS OBSERVAR, EN MEDIO DE LA RUTA SE ENCUENTRA NUESTRA VARIABLE "C", AL MOMENTO DE
* AUMENTAR DE 1 EN 1, INDICAMOS EL CORRIMIENTO DE FOTOGRAMAS DENTRO DE NUESTRA ANIMACIÓN*/
pictureBox1.ImageLocation = "C:/Users/Coraza de Tortuga/Pictures/Photoshop/Fotogramas/Zelda/ezgif-2-9dd5697ddc-gif-im/frame_"+c+"_delay-0.03s.gif";
if (c == 14) // COLOCAMOS UN IF PARA INDICAR LA ACCIÓN QUE REALIZARÁ DESPUÉS DE PRESENTAR EL ÚLTIMO FOTOGRAMA
{
c = 0; // CUANDO LLEGUE A 14, VA A VOLVER A EMPEZAR LA ANIMACIÓN DESDE EL INICIO FORMANDO UN BUCLE
}
}
// AQUÍ SE PROGRAMA LO QUE OCURRIRÁ AL PRESIONAR EL BOTÓN 3 (AVANZAR)
private void button3_Click(object sender, EventArgs e)
{
c++; // AVANZARÁ DE 1 EN 1 CADA FOTOGRAMA MANUALMENTE
// PRESENTARÁ EL FOTOGRAMA SIGUIENTE EN EL PICTUREBOX
pictureBox1.ImageLocation = "C:/Users/Coraza de Tortuga/Pictures/Photoshop/Fotogramas/Zelda/ezgif-2-9dd5697ddc-gif-im/frame_" + c + "_delay-0.03s.gif";
if (c == 14) // COLOCAMOS UN IF PARA INDICAR LA ACCIÓN QUE REALIZARÁ EN CASO DE PASAR DEL ÚLTIMO FOTOGRAMA
{
c = 0; // CUANDO LLEGUE A 14, SE REGRESARÁ AL PRIMER FOTOGRAMA
}
}
// AQUÍ SE PROGRAMA LO QUE OCURRIRÁ AL PRESIONAR EL BOTÓN 4 (RETROCEDER)
private void button4_Click(object sender, EventArgs e)
{
c--;// RETROCEDERÁ DE 1 EN 1 CADA FOTOGRAMA MANUALMENTE
// PRESENTARÁ EL FOTOGRAMA ANTERIOR EN EL PICTUREBOX
pictureBox1.ImageLocation = "C:/Users/Coraza de Tortuga/Pictures/Photoshop/Fotogramas/Zelda/ezgif-2-9dd5697ddc-gif-im/frame_" + c + "_delay-0.03s.gif";
if (c == 0)// COLOCAMOS UN IF PARA INDICAR LA ACCIÓN QUE REALIZARÁ DESPUÉS DE REGRESAR EN EL PRIMER FOTOGRAMA
{
c = 14;// CUANDO LLEGUE A 0, AVANZARÁ HASTA EL ÚLTIMO FOTOGRAMA
}
}
}
}
No hay comentarios.:
Publicar un comentario