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.
Head over and check out the full question and answer set about Firemonkey collision detection.
The colision example firemonkey doesn’t work on Android. I don’t know what I did. But, I copied the example to My Android. Lollipop version. The drag on drop doesn’t work. Why? The same example.
It was built for XE6 and earlier versions of Android. I’ll try to check it out under Lollipop and XE8 to see what changes need to be made if any.
upgraded the project to sydney. works on windows but not on android. the elements cannot be dragged at all.