1
마우스 끌기를 사용하여 삼각형을 그립니다. 많은 다른 삼각형을 그린 후에 마우스 드래그를 사용하여 삼각형을 다른 위치로 옮기고 싶었지만 삼각형을 다른 위치로 드래그하는 방법을 모르겠습니다. 도움말하십시오 = (마우스 드래그를 사용하여 삼각형을 이동하는 방법
마우스 끌기를 사용하여 삼각형을 그립니다. 많은 다른 삼각형을 그린 후에 마우스 드래그를 사용하여 삼각형을 다른 위치로 옮기고 싶었지만 삼각형을 다른 위치로 드래그하는 방법을 모르겠습니다. 도움말하십시오 = (마우스 드래그를 사용하여 삼각형을 이동하는 방법
베드로는 바로이 질문 마지막 시간이었다 (link)
여기에 그가 무엇에 대해 말하고에 자세히 설명하는 몇 가지 psudocode입니다 :., 새로운 I 마우스를 드래그
on mouse down: for each triangle, in reverse order of their drawing if the pointer is within the triangle's area set the "dragging" state in a member variable add a reference to the triangle to a member variable record the mouse position in a member variable record the initial position of the triangle in a member variable break end if end for on mouse move: if currently in the "dragging" state move the triangle by the same amount the mouse has moved end if on mouse up: if currently in the "dragging" state move the triangle by the same amount as the mouse has moved exit the "dragging" state end if
everytimes가 삼각형 그려 :-( – Jessy
당신이 페인트 메서드에서 배경을 다시 칠하는 것을 잊어 버린 것 같아요 super.paint (g)를 맨 위에 불러 오거나 Graphics :: clearRect (x, y, w, h) 삼각형을 그리기 전에 – Gunslinger47
감사합니다. 문제는 지금 해결되었습니다 :-) – Jessy