コード例 #1
0
        public void MouseUp(object sender, MouseEventArgs e)
        {
            if (objectDragging != null)
            {
                objectDragging.Location = new Point(e.Location.X - modelEditor.widthDragDropPanel - (objectDragging.Width / 2), e.Location.Y - (objectDragging.Height / 2));

                if (e.Location.X < (modelEditor.gamePanel.Location.X + modelEditor.widthDragDropPanel) || e.Location.X > (modelEditor.gamePanel.Location.X + modelEditor.gamePanel.Width)) {
                    gameObjects.Remove(objectDragging);
                }
                if(e.Location.Y < modelEditor.gamePanel.Location.Y || e.Location.Y > modelEditor.gamePanel.Height) {
                    gameObjects.Remove(objectDragging);
                }

                objectDragging = null;
                modelEditor.gamePanel.Invalidate();
            }
        }
コード例 #2
0
 public void MouseDown(object sender, MouseEventArgs e)
 {
     // Begin van drag and drop
     if (e.Button == MouseButtons.Left)
     {
         foreach (GameObject gameObject in gameObjects)
         {
             if (!(gameObject is Checkpoint))
             {
                 GameObject tempGameObject = new GameObject(new Point(e.Location.X - modelEditor.widthDragDropPanel, e.Location.Y), 40, 40);
                 if (gameObject.CollidesWith(tempGameObject))
                 {
                     objectDragging = gameObject;
                 }
             }
         }
     }
 }