基本上我正在制作电梯,我已经将机芯功能降下来,但现在我需要让它们打开和关闭。我尝试过一些东西,但似乎无法让它发挥作用。
按钮代码
private void CP_GFButton_Click(object sender, EventArgs e)
{
while (LDoor.Location.Y < 350)
while (Rdoor.Location.Y < 350)
{
LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y + 1); //Move Left Door DOWN
System.Threading.Thread.Sleep(10);
Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y + 1); // Move Right door DOWN
System.Threading.Thread.Sleep(10);
}
}
private void CP_OneFbutton_Click(object sender, EventArgs e)
// Move both lift doors up
{
while (LDoor.Location.Y > 90)
while (Level1.Location.Y > 90)
while (Rdoor.Location.Y > 90)
{
LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y - 4); // Move Left door UP
System.Threading.Thread.Sleep(10);
Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y - 4); //Move Right door UP
System.Threading.Thread.Sleep(10);
Level1.Location = new System.Drawing.Point(Level1.Location.X, Level1.Location.Y - 4); //Move Right door UP
System.Threading.Thread.Sleep(10);
}
}
尝试过的代码:
while (LDoor.Width > 5)
{
LDoor.Width--;
LDoor.Width--;
LDoor.Location = new Point(LDoor.Left + 1, LDoor.Top);
}
电梯的形象: