Separate names with a comma.
Discussion in 'iOS Programming' started by moonman239, Feb 22, 2014.
I can do this using math, but I don't want to if I don't have to.
CGPoints are numbers. You want to determine the relationship between two sets of numbers but you don't want to do math? I don't understand.
Write a function that hides the math and use that function. What difference does it make if you or Apple writes the function - it'll be implemented the same way either way.
I just want to do things the Apple way.
The less code I have to write, the better, and the more likely I get to blame someone else for not letting a portion of my app work.
Ok, to be fair I understand you not wanting to 'reinvent the wheel,' but honestly it should take you 30s to bang out this function.
If you're getting into games and not using Sprite Kit, I suggest using someone else's game libraries. Most of them will provide distance between points equations.
Also note that if you're looking to determine if a point is within a certain distance of another point, there's no need to use a sqrt function which will take a relatively long time to run.
dx = point2.x - point1.x;
dy = point2.y - point1.y;