Hello all Corona physics fans,
Good news! As of Daily Build #1123, the “hit order” issue of physics.rayCast() that’s inherent to Box2D has been fixed. Instead of supplying the maximum number of hits that you wish to detect (as the fifth argument), you now have three options to return exactly the hit(s) you need.
This property can be one of the following options:
- “any” — The first valid result, but not necessarily the closest to the starting point (behaves like before).
- “closest” — The closest result from the starting point (default return value if none is specified).
- “sorted” — all of the results, sorted from closest to furthest from the starting point.
Here’s the Daily Build documentation on it.
http://docs.coronalabs.com/daily/api/library/physics/rayCast.html
The raycasting tutorial and demo project have also been updated accordingly.
http://www.coronalabs.com/blog/2013/05/07/physics-raycasting-and-reflection/
Hopefully this is useful for you!
Brent Sorrentino