There is a question and answer set over on StackOverflow about collision detection in Delphi Firemonkey. One of the answers by developer ‘NGLN’ provided pretty good code for checking collisions between three types of Firemonkey objects. They are circles and rectangles, circles and circles, rectangles and circles, and finally round rectangles and circles. The collision detection is written to handle collisions between drag and drop operations but you can easily convert them to separate functions for handling collision detection in your own projects. I implemented and updated the sample source code into a demo mobile project for Delphi XE6 Firemonkey which you can download here. There is another answer by developer Scott Pritchard where he explains about all of the different bounding box properties that Firemonkey makes available. The bounding box properties are: AbsoluteRect, BoundsRect, LocalRect, UpdateRect, ParentedRect, ClipRect, ChildrenRect. I have had success using AbsoluteRect and ParentedRect but you’ll have to read the help on each to see which one you need to use. The drag and drop collision demo should work on Android, IOS, Windows, and OSX. You should be able to also get it working on Delphi XE5 and AppMethod without many changes. Also check out our previous post about a game which uses collision detection in Firemonkey. If all you need is simple rectangle collision detection check out the IntersectRect function. If you only need point based collision detection check out the PtInRect function.
Rectangle And Circle Collision Detection In Delphi XE6 Firemonkey On Android And IOS by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.