Witam, moja metoda ma przemieszczać rec o 25 w ciągu 1000ms przez cały czas. Czy moglibyście zobaczyć na ten kod i powiedzieć dlaczego ta metoda się nie wykonuje?
using Timer = System.Timers.Timer;
namespace CSSnake
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int sx = 0;
int sy = 0;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rec = new Rectangle(sx, sy, 25, 25);
SolidBrush white = new SolidBrush(Color.White);
g.FillRectangle(white, rec);
}
private Timer timer;
public void Timer()
{
timer = new Timer();
timer.Interval = 1000;
timer.Elapsed += new ElapsedEventHandler(sxsyMove);
}
private void sxsyMove(object sender, EventArgs e)
{
sx += 25;
}
}
}
Pozdrawiam.