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.

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Customize And Sort TListView LiveBindings Data With Firemonkey On Android And IOS

Sarina DuPont from Embarcadero has a new tutorial up which demonstrates how to customize your TListViews when using LiveBindings in Delphi...