Difference between revisions of "B2.ParticleSystem:createParticleGroup"

From GiderosMobile
(added example)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
 
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
'''Class:''' [[Special:MyLanguage/b2.ParticleSystem|b2.ParticleSystem]]<br/>
+
'''Class:''' [[b2.ParticleSystem]]<br/>
  
 
=== Description ===
 
=== Description ===
Creates a group of multiple particles with same properties, that can be defined in table with:
+
Creates a group of multiple particles with the same properties. The possible table properties are:
*''flags''
+
*'''''flags''''': the particle-behavior flags
*''groupFlags''
+
*'''''groupFlags''''': the group-construction flags
*''position''
+
*'''''position''''': the world position of the group. Moves the group's shape a distance equal to the value of position
*''angle''
+
*'''''angle''''': the world angle of the group in radians. Rotates the shape by an angle equal to the value of angle
*''linearVelocity''
+
*'''''linearVelocity''''': the linear velocity of the group's origin in world co-ordinates
*''angularVelocity''
+
*'''''angularVelocity''''': the angular velocity of the group
*''color''
+
*'''''color''''': the color of all particles in the group
*''alpha''
+
*'''''alpha''''': the alpha of all particles in the group
*''strength''
+
*'''''strength''''': the strength of cohesion among the particles in a group with flag b2.ParticleSystem.FLAG_ELASTIC or b2.ParticleSystem.FLAG_SPRING
*''shape''
+
*'''''shape''''': the shape where particles will be added
*''lifetime''
+
*'''''lifetime''''': lifetime of the particle group in seconds. A value <= 0.0f indicates a particle group with infinite lifetime
 
<source lang="lua">
 
<source lang="lua">
 
b2.ParticleSystem:createParticleGroup(particleGroupDef)
 
b2.ParticleSystem:createParticleGroup(particleGroupDef)
Line 22: Line 21:
  
 
=== Parameters ===
 
=== Parameters ===
'''particleGroupDef''': (table) table with particle group data <br/>
+
'''particleGroupDef''': (table) table with particle group data<br/>
  
 
=== Example ===
 
=== Example ===
Line 33: Line 32:
 
ps:setTexture(Texture.new("gfx/myparticle.png"))
 
ps:setTexture(Texture.new("gfx/myparticle.png"))
 
stage:addChild(ps)
 
stage:addChild(ps)
ps:createParticleGroup( { shape = shape, position = { x = 128, y = 128}, color = 0xffffff, alpha=1, flags=b2.ParticleSystem.FLAG_VISCOUS } )
+
ps:createParticleGroup({
 +
shape = shape,
 +
position = { x = 128, y = 128},
 +
color = 0xffffff,
 +
alpha=1,
 +
flags=b2.ParticleSystem.FLAG_VISCOUS,
 +
})
 
</source>
 
</source>
  
 
{{B2.ParticleSystem}}
 
{{B2.ParticleSystem}}

Revision as of 23:49, 22 April 2022

Available since: Gideros 2011.6
Class: b2.ParticleSystem

Description

Creates a group of multiple particles with the same properties. The possible table properties are:

  • flags: the particle-behavior flags
  • groupFlags: the group-construction flags
  • position: the world position of the group. Moves the group's shape a distance equal to the value of position
  • angle: the world angle of the group in radians. Rotates the shape by an angle equal to the value of angle
  • linearVelocity: the linear velocity of the group's origin in world co-ordinates
  • angularVelocity: the angular velocity of the group
  • color: the color of all particles in the group
  • alpha: the alpha of all particles in the group
  • strength: the strength of cohesion among the particles in a group with flag b2.ParticleSystem.FLAG_ELASTIC or b2.ParticleSystem.FLAG_SPRING
  • shape: the shape where particles will be added
  • lifetime: lifetime of the particle group in seconds. A value <= 0.0f indicates a particle group with infinite lifetime
b2.ParticleSystem:createParticleGroup(particleGroupDef)

Parameters

particleGroupDef: (table) table with particle group data

Example

require "liquidfun"
local world = b2.World.new(0, 9.8)
local shape = b2.PolygonShape.new()
shape:setAsBox(128, 128)
local ps = world:createParticleSystem( { radius = 16 } )
ps:setTexture(Texture.new("gfx/myparticle.png"))
stage:addChild(ps)
ps:createParticleGroup({
	shape = shape,
	position = { x = 128, y = 128},
	color = 0xffffff,
	alpha=1,
	flags=b2.ParticleSystem.FLAG_VISCOUS,
})





LiquidFun