Liquid Fun Group listeners

need an example for each just to invoke the function

tried

local group=testParticleSystem:createGroup(
    {
        flags = { ‘elastic’, ‘destructionListener’ },
       groupFlags = { ‘solid’ },
        x = centerX,
        y = 0,
        color = {math.random(),math.random(),math.random()},
       --radius = 32,
       halfWidth=48, halfHeight=16,
        lifetime=8
    }
)

group:addEventListener(‘destructionListener’, delete)

result:

Runtime error
c:\users\robert\desktop\liquid\cigrouplisteners\main.lua:55: attempt to index

local ‘group’ (a nil value)
stack traceback:
        c:\users\robert\desktop\liquid\cigrouplisteners\main.lua:55: in function
 ‘_listener’
        ?: in function <?:141>
        ?: in function <?:219>

 

Hi @bobcook47,

It doesn’t seem that you’re setting this up properly. First, you need to declare a “Particle System” using “physics.newParticleSystem()”:

http://docs.coronalabs.com/daily/api/library/physics/newParticleSystem.html

Then, you create a particle group for that object using the “:createGroup()” method. In your code, you’re trying to declare this in one step, but it’s actually a 2-step process. The docs show how it should be done.

Best regards,

Brent

Also, you won’t yet have access to LiquidFun physics as a Starter user. This is a recent addition to our daily builds, accessible to Pro/Enterprise users only.

brent

first, i do have pro access and have been writing test programs and submitting bug reports.

second, the msg just had a snippet of the code.

i attached a zip file but don’t see it in the post.

i need docs on how to connect methods to listeners and filters

local centerX = display.contentCenterX
local centerY = display.contentCenterY
local W = display.contentWidth
local H = display.contentHeight
display.setDefault( ‘background’, 1,1,1)

local physics=require(‘physics’)
physics.start()
physics.setGravity(0,9.8)

local obstacle = display.newRect( centerX, centerY*1.75, W, 4 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)
obstacle = display.newRect( W/10, centerY*1.75-150, 4, 300 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)
obstacle = display.newRect( W*9/10, centerY*1.75-150, 4, 300 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)

function touched(event)
  if event.phase==‘ended’ then
    local red = display.newImage( “red_balloon.png”, event.x, event.y )
    physics.addBody( red, { density = 0.4, friction = 0.1, bounce = 0.2, radius=43  } )
  end
end

Runtime:addEventListener( “touch”, touched ) – touch the screen to create balloons
–add liquid
local testParticleSystem = physics.newParticleSystem(
   {
      filename = “particle.png”,
      radius = 4,
      imageRadius = 5,
     elasticStrength = 0.5,  --greater than 1.5 not useful
   }
)
local function delete(a,b,c)
  print(a,b,c)
end --delete
local function onTimer( event )

   local group=testParticleSystem:createGroup(
    {
        flags = { ‘elastic’, ‘destructionListener’ },
       groupFlags = { ‘solid’ },
        x = centerX,
        y = 0,
        color = {math.random(),math.random(),math.random()},
       --radius = 32,
       halfWidth=48, halfHeight=16,
        lifetime=8
    }
)
–group:addEventListener(‘destructionListener’, delete)
end --onTimer

timer.performWithDelay( 2000, onTimer, 0 )

Hi @bobcook47,

I see… we’re planning to release a short tutorial on particle collisions soon. In the meantime, you can download a recent daily build and examine the sample projects in the application folder. They should be located in:

SampleCode > Physics > LiquidFun

Best regards,

Brent

Hi @bobcook47,

It doesn’t seem that you’re setting this up properly. First, you need to declare a “Particle System” using “physics.newParticleSystem()”:

http://docs.coronalabs.com/daily/api/library/physics/newParticleSystem.html

Then, you create a particle group for that object using the “:createGroup()” method. In your code, you’re trying to declare this in one step, but it’s actually a 2-step process. The docs show how it should be done.

Best regards,

Brent

Also, you won’t yet have access to LiquidFun physics as a Starter user. This is a recent addition to our daily builds, accessible to Pro/Enterprise users only.

brent

first, i do have pro access and have been writing test programs and submitting bug reports.

second, the msg just had a snippet of the code.

i attached a zip file but don’t see it in the post.

i need docs on how to connect methods to listeners and filters

local centerX = display.contentCenterX
local centerY = display.contentCenterY
local W = display.contentWidth
local H = display.contentHeight
display.setDefault( ‘background’, 1,1,1)

local physics=require(‘physics’)
physics.start()
physics.setGravity(0,9.8)

local obstacle = display.newRect( centerX, centerY*1.75, W, 4 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)
obstacle = display.newRect( W/10, centerY*1.75-150, 4, 300 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)
obstacle = display.newRect( W*9/10, centerY*1.75-150, 4, 300 )
obstacle:setFillColor( 0, 1, 0)
physics.addBody( obstacle, “static”)

function touched(event)
  if event.phase==‘ended’ then
    local red = display.newImage( “red_balloon.png”, event.x, event.y )
    physics.addBody( red, { density = 0.4, friction = 0.1, bounce = 0.2, radius=43  } )
  end
end

Runtime:addEventListener( “touch”, touched ) – touch the screen to create balloons
–add liquid
local testParticleSystem = physics.newParticleSystem(
   {
      filename = “particle.png”,
      radius = 4,
      imageRadius = 5,
     elasticStrength = 0.5,  --greater than 1.5 not useful
   }
)
local function delete(a,b,c)
  print(a,b,c)
end --delete
local function onTimer( event )

   local group=testParticleSystem:createGroup(
    {
        flags = { ‘elastic’, ‘destructionListener’ },
       groupFlags = { ‘solid’ },
        x = centerX,
        y = 0,
        color = {math.random(),math.random(),math.random()},
       --radius = 32,
       halfWidth=48, halfHeight=16,
        lifetime=8
    }
)
–group:addEventListener(‘destructionListener’, delete)
end --onTimer

timer.performWithDelay( 2000, onTimer, 0 )

Hi @bobcook47,

I see… we’re planning to release a short tutorial on particle collisions soon. In the meantime, you can download a recent daily build and examine the sample projects in the application folder. They should be located in:

SampleCode > Physics > LiquidFun

Best regards,

Brent