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.

close

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

Related posts
AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

DelphiIDEShowcaseWindows

Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

DelphiFiremonkeyIDEIOSOSXWindows

DelphiCon 2020 FireMonkey Sessions Available Starting November 19

AndroidC++BuilderDelphiDemoFiremonkeyWindows

Powerful Commercial Gorilla3D Framework Upgraded For Delphi FireMonkey On Windows And Android

Sign up for our Newsletter and
stay informed

Leave a Reply