C#--不断向左移动的小动画之猫鼠赛跑
来源:互联网 发布:阿里旺旺 mac 编辑:程序博客网 时间:2024/05/20 07:14
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;namespace WindowsFormsApplication4{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { this.pictureBox1.Left -=3; if (this.pictureBox1.Right < 0) { this.pictureBox1.Left = this.Width; } } private void button1_Click(object sender, EventArgs e) { this.timer1.Start(); } private void button2_Click(object sender, EventArgs e) { this.timer2.Start(); } private void button3_Click(object sender, EventArgs e) { Close(); } private void Form1_Load(object sender, EventArgs e) { } private void timer2_Tick(object sender, EventArgs e) { this.pictureBox2.Left -= 3; if (this.pictureBox2.Right < 0) { this.pictureBox2.Left = this.Width; } } private void button4_Click(object sender, EventArgs e) { this.timer1.Stop(); } }}