Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

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.

Related posts
AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

AndroidC++BuilderDelphiFiremonkeyIOSLiveBindingsOSXWindows

Top Tips And Tricks To Speed Up Development With Delphi 10.4 FireMonkey On Android and IOS

Sign up for our Newsletter and
stay informed

3 Comments

Leave a Reply