2013-12-12 107 views
-3

我有一個向上移動對象的按鈕。我只是想知道我有什麼改變,使其向下移動(不同的按鈕)向下移動一個對象,C#

private void CP_GFButton_Click(object sender, EventArgs e) 
     { 
      while (LDoor.Location.Y < 0) 
       while (Rdoor.Location.Y < 0) 
       { 
        LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y - 1); 
        System.Threading.Thread.Sleep(10); 

        Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y - 1); 
        System.Threading.Thread.Sleep(10); 
       } 
     } 
+2

如果從'Y'使得上去減,然後加入到'Y'應該使它下去吧? – Houseman

回答

0
 while (LDoor.Location.Y < MaxVal) 
      while (Rdoor.Location.Y < MaxVal) 
      { 
       LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y + 1); 
       System.Threading.Thread.Sleep(10); 

       Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y + 1); 
       System.Threading.Thread.Sleep(10); 
      } 
+0

這幫了很多。你有什麼想法,我怎麼能讓門開着,並且有任何機會靠近自己? – user3097273

相關問題