diff --git a/net/flashpunk/World.as b/net/flashpunk/World.as index aa9163b..766c9e1 100644 --- a/net/flashpunk/World.as +++ b/net/flashpunk/World.as @@ -995,6 +995,31 @@ } } + /** + * Returns the Entity at front which collides with the point. + * @param x X position + * @param y Y position + * @return The Entity at front which collides with the point, or null if not found. + */ + public function frontCollidePoint(x:Number, y:Number):Entity + { + var e:Entity, + i:int = 0, + l:int = _layerList.length; + do + { + e = _renderFirst[_layerList[i]]; + while (e) + { + if(e.collidePoint(e.x, e.y, x, y)) return e; + e = e._renderNext + } + if(i > l) break; + } + while(++i); + return null; + } + /** @private Adds Entity to the update list. */ private function addUpdate(e:Entity):void {