0
나는 위치와 previousLocation 두 CGPoint있는이 코드를 가지고 :IOS : 차이가보기에 접촉
CGRect bounds = [self bounds];
UITouch *touch = [[event touchesForView:self] anyObject];
CGPoint point = [touch locationInView:self];
location = CGPointMake(point.x,point.y);
location.y = bounds.size.height - location.y;
CGPoint prev = [touch previousLocationInView:self];
previousLocation = CGPointMake(prev.x, prev.y);
previousLocation.y = bounds.size.height - previousLocation.y;
[self renderLineFromPoint:previousLocation toPoint:location];
확인이 내 GLPaint 응용 프로그램의 "touchmoved"내부에 코드의 일부입니다; 하지만 내 문제는 픽처 포인트의 정점에있는 이전 위치와 이전 위치를 바꾸고 싶다는 것입니다. 뷰를 터치하면 이미지를 드래그하기 때문에이 지점을 지정할 수 있습니다.
CGPoint *vertex = (imageView.center.x-100, imageView.center.y+100);
그래서 내 코드 변경 :
CGRect bounds = [self bounds];
UITouch *touch = [[event touchesForView:self] anyObject];
//CGPoint point = [touch locationInView:self];
location = CGPointMake(vertex.x,vertex.y);
location.y = bounds.size.height - location.y;
//CGPoint prev = [touch previousLocationInView:self];
previousLocation = CGPointMake(prev.x, prev.y); <---- ?????
previousLocation.y = bounds.size.height - previousLocation.y;
[self renderLineFromPoint:previousLocation toPoint:location];
위치를 쉽게 변경할 수 있습니다하지만 내 문제는 지금 previousLocation, 내가 그것을 어떻게 변경할 수 있습니까? 그렇다면 제 질문은 ... 위치와 이전 위치의 차이를 아는 방법은 무엇입니까? 어떻게 그 차이를 계산할 수 있습니까? 내가 올바른 시프트 previousLocation을 설정할 수 있습니다 dinamic 차이 ...
죄송합니다, 나는 당신이 pratically ... 여기 – jimpic
을 무엇을하려고하지 않습니다 나는 위치와 이전 위치의 차이점을 알고 그 차이를 계산하고 싶다 ... – CrazyDev
CGPoint gap = CGPointMake (cur.x - prev.x, cur.y - prev.y); ? – jimpic