0
我在C#窗体表单应用程序中创建了一个彩弹射击游戏。我需要它,所以当你左键点击作为图片框的目标(ptrEinstein)时,它会出现一个消息框。下面是我的form1。用鼠标点击图片框的事件ptrEinstein
namespace AmazingPaintball
{
public partial class Form1 : Form
{
Random positionX = new Random();
Random positionY = new Random();
Target einstein;
int count = 0;
Paintballs pBalls = new Paintballs();
Stopwatch stopwatch = new Stopwatch();
public Form1()
{
InitializeComponent();
Point point = new Point(positionX.Next(0, 638), positionY.Next(0, 404));
einstein = new Target(point);
ptrEinstein.Location = point;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
pBalls.paint(e.Graphics);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
ptrEinstein.Location = einstein.Move(e.KeyData);
pictureBox1.Update();
pictureBox1.Refresh();
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
pBalls.add(e.Location);
pictureBox1.Refresh();
if (ptrEinstein.Location == ??)
{
stopwatch.Stop();
MessageBox.Show("It took " + count + " shots and " + stopwatch.Elapsed + " seconds to hit the target");
}
count++;
}
private void Form1_Load(object sender, EventArgs e)
{
stopwatch.Start();
}
}
}
在picturebox1_click是问题似乎是。我需要它,当我点击ptrEinstein时,消息框出现。请让我知道如果没有足够的信息。谢谢
请提供有关确切的错误或问题的信息。你想实现的目标是什么 – 2014-08-31 16:27:26
你的意思是说__two__ pictureboxes?如果是这样,他们有__two distinct__ MouseClick事件,你会想要脚本。 – TaW 2014-08-31 16:35:03