Im making an iPhone app where the user draws a line with their finger (the line will be straight line between where the touch began and ended). I also have a ball which will fall and hit the line. What is the best / easiest way of handling the i) drawing, and ii) collisions?
I am completely new to this and open to any ideas or so开发者_如何转开发urce code.
I have decided to use CoreGraphics to draw the line, and to store the points in cgpoint arrays. Then, I use the parallel distance formula to calculate when the distance of the ball to the line nears zero (funny, it has never equaled zero, even though the timer repeats every 0.01). Then a collision has taken place, and I use simple applied maths vectors to calculate the resultant is the coefficient of restitution is 1
精彩评论