Welcome to what I hope will be the first of many posts in which I share, not only my progress with application development, but hopefully something useful that you may be able to use in your own projects.
A search on YouTube and Google showed some interesting implementations on various platforms (Flash and Java), but I couldn't find anything related to Corona SDK or Lua that I could dissect, learn from and implement myself. I will add here, that I am new to programming in general (about 6 weeks in), and porting from another scripting language, whilst trying to learn the target scripting language is unfortunately beyond my scope at this point.
So, I decided to have a go at creating the buoyancy myself. After all, this best way to learn is by diving in (no pun intended) and doing it yourself.
The maths may not be perfect, but I think that the effect looks good and, more importantly, pretty realistic.
In this example, I've added a 'Settings' section that allows simple changing of:
Number of Boxes
Box Size
Liquid Density
The liquid density allows the user to control how viscous the liquid is. The default setting of 1.0 simulates water, and the higher the number, the more viscous the fluid becomes. A setting of 2.5 here simulates something similar to oil etc.
In a future update, I will be modularising the code to make it more flexible, and support various display objects etc.
Get the code here:
http://insertcode.co.uk/2011/10/water-buoyancy-in-corona-sdk/
Well done! Looks perfect!
jkrassman 4 months ago
@jkrassman Thanks, I'm glad you like it and if you can use it in one of your projects then feel free to do so without restriction. If you do, why not let me know and I'll see about blogging about it with a link back to your web site?
insertcodegames 4 months ago