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

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Simulate Liquid Buoyancy With Box2d In Delphi XE6 Firemonkey On Android And IOS

Delphi XE6 Firemonkey Box2d Water Buoyancy DemoOne of the sample projects included with Box2d Firemonkey for Delphi XE5 & XE6 on Android and IOS is a Buoyancy Controller project. The code also works cross platform on Windows and OSX. The Buyancy Controller demo shows you how to give setup an object to simulate water and how to assign buoyance to your objects so that they will float in the simulated water. Box2d Firemonkey is a full featured physics engine already so adding this functionality to your project is pretty simple. It might be interesting to modify this project so that the water in the demo is based on the mobile device orientation. Here is some sample code for setting up the buoyancy values on a Box2d body:

And here is the sample code from the Step function which shows how the water is handled and drawn:

Download the Box2d Firemonkey for Delphi XE5 and XE6 Firemonkey with Buoyancy Controller Demo. Or access the Buoyancy Controller Demo unit on Github.

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


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


Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows


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

Leave a Reply