views:

596

answers:

2

I'm trying to create a rotating object for the iPhone. I have it calculating all the trig. The problem is that for my project I have need to have the program reset the x and y every time a finger is dragged more over then 30 degrees around the center point. Whenever I link a variable to the x and y of the current location within the touchesMoved function they link permanently and continually change along with the drag event instead of staying constant and updating every 30 degrees. Is there a way to statically store an x and y?

Kailoa Kadano, already did that and it still linked and updated. Code: currentpoint = [touch locationInView:self.view]; when angle between startpoint and currentpoint >= 30 degrees set altpoint = currentpoint, I did that using CGPointMake and it didn't work. altpoint continually updated to currentpoint

+1  A: 

Use the CGPoint struct.

CGPoint point = CGPointMake(1,2); point.x // 1 point.y // 2

Kailoa Kadano
A: 

Be sure to declare CGPoint startPoint in your classes .h file, and then update the value within your touchesBegan implementation with:

startPoint = CGPointMake(point1.x, point1.y);

As specified by Kailoa above. Then, in your touchesMoved implementation, you can do a check to see if the new point is more than 30 degrees separation, and if so, update startPoint.

If the above isn't what you are looking for, please post more details/example code.

Mark Hammonds