Hi Brent,
It’s pretty much the same as the many examples given. In fact, I copied it from one of Corona examples. It’s working in the game the way I intended it to do EXCEPT that I still wanted to tweak it’s drop characteristic to mimic how liquids in real life (and other box2D physics bodies) drop. Imagine a newCircle obj with a gravity scale of 4 or 5 in a normal 9.8 gravity - that’s the kind of drop I wanted.
I think liquid fun is designed to work as large blobs or “mass” of particles to simulate liquid, rather than as single isolated particle.
To illustrate what I mean, please consider the two codes below:
This code is using particle system, working on single particles at a time: (NOTE: You can copy the particle.png in the Corona liquid fun examples)
-- main.lua local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static" ) center\_piece.rotation = 15 -- Create particles -- local particleSystem = physics.newParticleSystem { filename = "particle.png", radius = 2, imageRadius = 2, --gravityScale = 4, --density = 1.5, } particleSystem.name = "acid" -- define particle params local particleParams = { flags = {"water", "fixtureContactListener" }, -- fixtureContactListener for later collision color = { 1, .50, 0, 1 }, x = display.contentCenterX, y = display.contentCenterY - 100, --velocityX = 300, --velocityY = 500, lifetime = 10, radius = 2, } -- Generate particles "droplets" local function onTimer( event ) particleSystem:createParticle( particleParams ) end timer.performWithDelay( 1000, onTimer, -1 ) -- end main.lua
Notice how the “droplets” seem to be just transitioned to with a slow time. They don’t seem to be pulled by gravity in a more natural way. Changing gravityScale and density doesn’t appear to have any effect at all.
Now look at this code using newCircle. Watch how the circles drop:
--- using newCircle as droplets ---- local physics = require( "physics" ) physics.start() display.setStatusBar( display.HiddenStatusBar ) local center\_piece = display.newRect( display.contentCenterX, display.contentHeight-135, 200, 10 ) physics.addBody( center\_piece, "static", {bounce=0, friction=0} ) center\_piece.rotation = 15 -- Generate the "drops" local function onTimer( event ) local droplet = display.newCircle( display.contentCenterX, display.contentCenterY-100, 2 ) droplet:setFillColor(1, 1, 0, 1) physics.addBody(droplet, "dynamic", {density=1.5, friction=0, bounce=0} ) droplet.gravityScale = 4 end timer.performWithDelay( 1000, onTimer, 10 ) -- end main.lua
Notice how the “droplets” drop like real gravity pulled them This is the particle drop behavior I wanted.
If somebody can help me get the latter drop effect for the particle system, I’ll be very happy
The reason I prefer to use particle system over the newCircle “droplets” is I want those droplets to accumulate in a container, and thereafter behave like liquid .
Cheers,
Santi