Beispiel #1
0
        public void mouseDown(MouseEventArgs e)
        {
            for (int i = objectList.Count - 1; i >= 0; i--) {
                BaseObject currentObject = objectList[i];
                if (hitTest(currentObject, e.X, e.Y)) {
                    draggingObject = currentObject;
                    dragShiftX = e.X - (int)currentObject.position.X;
                    dragShiftY = e.Y - (int)currentObject.position.Y;
                    break;
                }
            }

            mouseMove(e);
        }
Beispiel #2
0
 public void mouseUp(MouseEventArgs e)
 {
     mouseMove(e);
     draggingObject = null;
 }
Beispiel #3
0
        private bool hitTest(BaseObject obj, int x, int y)
        {
            if (!(x >= obj.position.X && x <= obj.position.X + obj.size.Width && y >= obj.position.Y && y <= obj.position.Y + obj.size.Height)) {
                return false;
            }

            Bitmap bitmap = obj.getBitmap();
            if (bitmap.GetPixel(x - (int)obj.position.X, y - (int)obj.position.Y).A < 5) {
                return false;
            }

            return true;
        }