나는 C# windows 폼 응용 프로그램에서 페인트 볼 게임을 만들고 있습니다. 나는 그것이 그림 상자 인 표적 (ptrEinstein)을 왼쪽으로 클릭 할 때 메시지 상자와 함께 나타납니다. 여기에 제 1 양식이 있습니다. 문제가 될 나타나는 위치 picturebox1_click에서그림 상자에 마우스 커서가있는 이벤트 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();
}
}
}
이다. ptrEinstein을 클릭하면 메시지 상자가 나타납니다. 정보가 충분하지 않으면 알려주세요. 당신은 당신이 "ptrEinstein"라는 두 번째의 PictureBox를 정말 확실하다면, 당신은 ptrEinstein_MouseClick 방법 대신 pictureBox1_MouseClick에서 그것을 작성 아래의 라인을 작성해야 당신
정확한 오류나 문제에 대한 정보를 제공해주십시오. 그리고 당신이 원하는 목표는 무엇입니까 –
__two__ 그림 상자가 있다는 것을 의미합니까? 그렇다면 그들은 __two distinct__ MouseClick 이벤트를 스크립트로 작성하려고합니다. – TaW