Difference between revisions of "B2.ParticleSystem"

From GiderosMobile
m (Text replacement - "</source" to "</syntaxhighlight")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
 
 
<!-- GIDEROSOBJ:b2.ParticleSystem -->
 
<!-- GIDEROSOBJ:b2.ParticleSystem -->
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
+
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
'''<translate>Available since</translate>:''' Gideros 2015.06.30<br/>
+
'''Available since:''' Gideros 2015.06.30<br/>
=== <translate>Description</translate> ===
+
 
<translate>Defines particle system in box2d world using Liquid fun</translate>
+
=== Description ===
=== <translate>Examples</translate> ===
+
Defines a particle system in box2d world using LiquidFun.
'''Simple particle system example'''<br/>
+
 
<source lang="lua">-- create world
+
=== Examples ===
 +
'''Simple particle system example'''
 +
<syntaxhighlight lang="lua">
 +
-- create world
 
local world = b2.World.new(0, 9.8)
 
local world = b2.World.new(0, 9.8)
  
local ps1= world:createParticleSystem({ radius=5})
+
local ps1 = world:createParticleSystem({ radius=5})
 
ps1:setTexture(Texture.new("Bubble.png"))
 
ps1:setTexture(Texture.new("Bubble.png"))
 
stage:addChild(ps1)
 
stage:addChild(ps1)
  
ps1:createParticleGroup({shape=shape2,  
+
ps1:createParticleGroup({shape=shape2,
position={x=500,y=250},
+
position={x=500,y=250},
color = 0xFF0000,
+
color = 0xFF0000,
alpha=1,
+
alpha=1,
flags=0
+
flags=b2.ParticleSystem.FLAG_COLOR_MIXING | b2.ParticleSystem.FLAG_POWDER,
 
})
 
})
  
 
ps1:createParticleGroup({shape=shape1,  
 
ps1:createParticleGroup({shape=shape1,  
position={x=400,y=50},
+
position={x=400,y=50},
color = 0x0000FF,
+
color = 0x0000FF,
alpha=1,
+
alpha=1,
flags=0
+
flags=0
 
})
 
})
 
  
 
-- step the world and then update the position and rotation of sprites
 
-- step the world and then update the position and rotation of sprites
Line 35: Line 36:
 
end
 
end
  
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)</source>
+
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
 +
</syntaxhighlight>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/b2.ParticleSystem:containsParticle|b2.ParticleSystem:containsParticle]] <br/><!-- GIDEROSMTD:b2.ParticleSystem:containsParticle(id) -->
+
[[b2.ParticleSystem:containsParticle]] <br/><!--GIDEROSMTD:b2.ParticleSystem:containsParticle(id) -->
[[Special:MyLanguage/b2.ParticleSystem:createParticle|b2.ParticleSystem:createParticle]] ''<translate>create new particle</translate>''<br/><!-- GIDEROSMTD:b2.ParticleSystem:createParticle(particleDef) create new particle -->
+
[[b2.ParticleSystem:createParticle]] ''creates a new particle system''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticle(particleDef) creates a new particle system-->
[[Special:MyLanguage/b2.ParticleSystem:createParticleGroup|b2.ParticleSystem:createParticleGroup]] ''<translate>create group of particles</translate>''<br/><!-- GIDEROSMTD:b2.ParticleSystem:createParticleGroup(particleGoupDef) create group of particles -->
+
[[b2.ParticleSystem:createParticleGroup]] ''creates a group of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticleGroup(particleGoupDef) creates a group of particles-->
[[Special:MyLanguage/b2.ParticleSystem:destroyParticle|b2.ParticleSystem:destroyParticle]] ''<translate>destroy particle by id</translate>''<br/><!-- GIDEROSMTD:b2.ParticleSystem:destroyParticle(id) destroy particle by id -->
+
[[b2.ParticleSystem:destroyParticle]] ''destroys a particle by id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticle(id) destroys a particle by id-->
[[Special:MyLanguage/b2.ParticleSystem:destroyParticles|b2.ParticleSystem:destroyParticles]] <br/><!-- GIDEROSMTD:b2.ParticleSystem:destroyParticles(ids) -->
+
[[b2.ParticleSystem:destroyParticles]] ''destroys multiple particles by their id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticles(ids) destroys multiple particles by their id-->
[[Special:MyLanguage/b2.ParticleSystem:getParticleCount|b2.ParticleSystem:getParticleCount]] <br/><!-- GIDEROSMTD:b2.ParticleSystem:getParticleCount() -->
+
[[b2.ParticleSystem:getParticleCount]] ''gets the number of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleCount() gets the number of particles-->
[[Special:MyLanguage/b2.ParticleSystem:getParticleGroupList|b2.ParticleSystem:getParticleGroupList]] <br/><!-- GIDEROSMTD:b2.ParticleSystem:getParticleGroupList() -->
+
[[b2.ParticleSystem:getParticleGroupList]] '' ''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleGroupList() -->
[[Special:MyLanguage/b2.ParticleSystem:setTexture|b2.ParticleSystem:setTexture]] ''<translate>set texture to particles</translate>''<br/><!-- GIDEROSMTD:b2.ParticleSystem:setTexture(texture,size) set texture to particles -->
+
[[b2.ParticleSystem:setTexture]] ''sets a texture to particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:setTexture(texture,size) sets a texture to particles-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
[[Special:MyLanguage/b2.ParticleSystem.FLAG_COLOR_MIXING|b2.ParticleSystem.FLAG_COLOR_MIXING]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_COLOR_MIXING 256-->
+
[[b2.ParticleSystem.FLAG_BARRIER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_BARRIER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_ELASTIC|b2.ParticleSystem.FLAG_ELASTIC]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_ELASTIC 16-->
+
[[b2.ParticleSystem.FLAG_COLOR_MIXING]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_COLOR_MIXING 256-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_POWDER|b2.ParticleSystem.FLAG_POWDER]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_POWDER 64-->
+
[[b2.ParticleSystem.FLAG_DESTRUCTION_LISTENER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_DESTRUCTION_LISTENER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_SPRING|b2.ParticleSystem.FLAG_SPRING]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_SPRING 8-->
+
[[b2.ParticleSystem.FLAG_ELASTIC]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_ELASTIC 16-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_TENSILE|b2.ParticleSystem.FLAG_TENSILE]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_TENSILE 128-->
+
[[b2.ParticleSystem.FLAG_FIXTURE_CONTACT_FILTER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_FIXTURE_CONTACT_FILTER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_VISCOUS|b2.ParticleSystem.FLAG_VISCOUS]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_VISCOUS 32-->
+
[[b2.ParticleSystem.FLAG_FIXTURE_CONTACT_LISTENER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_FIXTURE_CONTACT_LISTENER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_WALL|b2.ParticleSystem.FLAG_WALL]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_WALL 4-->
+
[[b2.ParticleSystem.FLAG_PARTICLE_CONTACT_FILTER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_PARTICLE_CONTACT_FILTER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_WATER|b2.ParticleSystem.FLAG_WATER]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_WATER 0-->
+
[[b2.ParticleSystem.FLAG_PARTICLE_CONTACT_LISTENER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_PARTICLE_CONTACT_LISTENER x-->
[[Special:MyLanguage/b2.ParticleSystem.FLAG_ZOMBIE|b2.ParticleSystem.FLAG_ZOMBIE]]<br/><!-- GIDEROSCST:b2.ParticleSystem.FLAG_ZOMBIE 2-->
+
[[b2.ParticleSystem.FLAG_POWDER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_POWDER 64-->
 +
[[b2.ParticleSystem.FLAG_REACTIVE]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_REACTIVE x-->
 +
[[b2.ParticleSystem.FLAG_REPULSIVE]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_REPULSIVE x-->
 +
[[b2.ParticleSystem.FLAG_SPRING]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_SPRING 8-->
 +
[[b2.ParticleSystem.FLAG_STATIC_PRESSURE]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_STATIC_PRESSURE x-->
 +
[[b2.ParticleSystem.FLAG_TENSILE]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_TENSILE 128-->
 +
[[b2.ParticleSystem.FLAG_VISCOUS]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_VISCOUS 32-->
 +
[[b2.ParticleSystem.FLAG_WALL]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_WALL 4-->
 +
[[b2.ParticleSystem.FLAG_WATER]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_WATER 0-->
 +
[[b2.ParticleSystem.FLAG_ZOMBIE]]<br/><!--GIDEROSCST:b2.ParticleSystem.FLAG_ZOMBIE 2-->
 
|}
 
|}
 +
 +
----
 +
*'''[[LiquidFun]]'''

Latest revision as of 18:07, 12 July 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2015.06.30

Description

Defines a particle system in box2d world using LiquidFun.

Examples

Simple particle system example

-- create world
local world = b2.World.new(0, 9.8)

local ps1 = world:createParticleSystem({ radius=5})
ps1:setTexture(Texture.new("Bubble.png"))
stage:addChild(ps1)

ps1:createParticleGroup({shape=shape2,
	position={x=500,y=250},
	color = 0xFF0000,
	alpha=1,
	flags=b2.ParticleSystem.FLAG_COLOR_MIXING | b2.ParticleSystem.FLAG_POWDER,
})

ps1:createParticleGroup({shape=shape1, 
	position={x=400,y=50},
	color = 0x0000FF,
	alpha=1,
	flags=0
})

-- step the world and then update the position and rotation of sprites
local function onEnterFrame()
	world:step(1/60, 8, 3)
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)

Methods

b2.ParticleSystem:containsParticle
b2.ParticleSystem:createParticle creates a new particle system
b2.ParticleSystem:createParticleGroup creates a group of particles
b2.ParticleSystem:destroyParticle destroys a particle by id
b2.ParticleSystem:destroyParticles destroys multiple particles by their id
b2.ParticleSystem:getParticleCount gets the number of particles
b2.ParticleSystem:getParticleGroupList
b2.ParticleSystem:setTexture sets a texture to particles

Events

Constants

b2.ParticleSystem.FLAG_BARRIER
b2.ParticleSystem.FLAG_COLOR_MIXING
b2.ParticleSystem.FLAG_DESTRUCTION_LISTENER
b2.ParticleSystem.FLAG_ELASTIC
b2.ParticleSystem.FLAG_FIXTURE_CONTACT_FILTER
b2.ParticleSystem.FLAG_FIXTURE_CONTACT_LISTENER
b2.ParticleSystem.FLAG_PARTICLE_CONTACT_FILTER
b2.ParticleSystem.FLAG_PARTICLE_CONTACT_LISTENER
b2.ParticleSystem.FLAG_POWDER
b2.ParticleSystem.FLAG_REACTIVE
b2.ParticleSystem.FLAG_REPULSIVE
b2.ParticleSystem.FLAG_SPRING
b2.ParticleSystem.FLAG_STATIC_PRESSURE
b2.ParticleSystem.FLAG_TENSILE
b2.ParticleSystem.FLAG_VISCOUS
b2.ParticleSystem.FLAG_WALL
b2.ParticleSystem.FLAG_WATER
b2.ParticleSystem.FLAG_ZOMBIE