写真: http://gyazo.com/e3bd39a4a967f4cd331f731fd6920702
写真の赤い十字はマウスの位置を表しています。
ボックスをドラッグすると、左上隅にあるボックスをつかみ続けます。マウスがボックスをつかみ始めた位置からボックスをつかむように、このコードを変更するにはどうすればよいですか。
これが私のコードです: (GraphicsAlignment.settings = ボックスのポイント) (グラブ可能領域のサイズ 200x20)
if (Mouse.isDragging) {
Point pressed = Mouse.pressed;
if ((pressed.x > GraphicsAlignment.settings.x && pressed.x < GraphicsAlignment.settings.x + 200
&& pressed.y > GraphicsAlignment.settings.y && pressed.y < GraphicsAlignment.settings.y + 20)
|| isEnabled) {
GraphicsAlignment.settings.x = Mouse.dragged.x;
GraphicsAlignment.settings.y = Mouse.dragged.y;
Boot.getDisplayApplet().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
isEnabled = true;
} else {
Boot.getDisplayApplet().setCursor(Cursor.getDefaultCursor());
}
} else {
isEnabled = false;
Boot.getDisplayApplet().setCursor(Cursor.getDefaultCursor());
}