Rectangle And Circle Collision Detection In Delphi XE6 Firemonkey On Android And IOS

Delphi XE6 Firemonkey Collision DetectionThere 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.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

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.

3 Responses to Rectangle And Circle Collision Detection In Delphi XE6 Firemonkey On Android And IOS

  1. João Henrique Gonçalves says:

    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.

    • Admin says:

      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.

  2. Pingback: Drag And Drop Tutorial With Source For Firemonkey In Delphi 10 Seattle On Android And IOS | Delphi XE5 XE6 XE7 XE8 10 Seattle Firemonkey, Delphi Android, Delphi IOS

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Delphi XE6 Firemonkey Read SMS Android
Read SMS Messages With The JNI API In Delphi XE6 Firemonkey on Android

Developer Andrey Yefimov has a blog post up where he demonstrates how to read a list of SMS messages into...

Close