Corona SDK Water Buoyancy Example (With Code)

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,377
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Oct 10, 2011

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/

Category:

Gaming

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (insertcodegames)

  • Well done! Looks perfect!

  • @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?

see all

All Comments (6)

Sign In or Sign Up now to post a comment!
  • Insertcode is a boss

  • Nice work :)

  • I might use this in something. It just gave me an insta-idea!

  • Nice. Thanks a lot.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more