Difference between revisions of "B2.ParticleSystem"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 37: | Line 37: | ||
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) | stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== Methods === | === Methods === | ||
− | [[b2.ParticleSystem:containsParticle]] <br/><!--GIDEROSMTD:b2.ParticleSystem:containsParticle(id) --> | + | [[b2.ParticleSystem:containsParticle]] ''whether a particle is in the particle system''<br/><!--GIDEROSMTD:b2.ParticleSystem:containsParticle(id) whether a particle is in the particle system--> |
[[b2.ParticleSystem:createParticle]] ''creates a new particle system''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticle(particleDef) creates a new particle system--> | [[b2.ParticleSystem:createParticle]] ''creates a new particle system''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticle(particleDef) creates a new particle system--> | ||
[[b2.ParticleSystem:createParticleGroup]] ''creates a group of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticleGroup(particleGoupDef) creates a group of particles--> | [[b2.ParticleSystem:createParticleGroup]] ''creates a group of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:createParticleGroup(particleGoupDef) creates a group of particles--> | ||
[[b2.ParticleSystem:destroyParticle]] ''destroys a particle by id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticle(id) destroys a particle by id--> | [[b2.ParticleSystem:destroyParticle]] ''destroys a particle by id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticle(id) destroys a particle by id--> | ||
[[b2.ParticleSystem:destroyParticles]] ''destroys multiple particles by their id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticles(ids) destroys multiple particles by their id--> | [[b2.ParticleSystem:destroyParticles]] ''destroys multiple particles by their id''<br/><!--GIDEROSMTD:b2.ParticleSystem:destroyParticles(ids) destroys multiple particles by their id--> | ||
+ | [[b2.ParticleSystem:getColorBuffer]] ''gets the color of each particle''<br/><!--GIDEROSMTD:b2.ParticleSystem:getColorBuffer() gets the color of each particle--> | ||
[[b2.ParticleSystem:getParticleCount]] ''gets the number of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleCount() gets the number of particles--> | [[b2.ParticleSystem:getParticleCount]] ''gets the number of particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleCount() gets the number of particles--> | ||
− | [[b2.ParticleSystem:getParticleGroupList]] '' ''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleGroupList() --> | + | [[b2.ParticleSystem:getParticleGroupList]] ''gets the particles group list''<br/><!--GIDEROSMTD:b2.ParticleSystem:getParticleGroupList() gets the particles group list--> |
+ | [[b2.ParticleSystem:getPositionBuffer]] ''gets the position of each particle''<br/><!--GIDEROSMTD:b2.ParticleSystem:getPositionBuffer() gets the position of each particle--> | ||
+ | [[b2.ParticleSystem:getVelocityBuffer]] ''gets the velocity of each particle''<br/><!--GIDEROSMTD:b2.ParticleSystem:getVelocityBuffer() gets the velocity of each particle--> | ||
+ | [[b2.ParticleSystem:getWeightBuffer]] ''gets the weight of each particle''<br/><!--GIDEROSMTD:b2.ParticleSystem:getWeightBuffer() gets the weight of each particle--> | ||
[[b2.ParticleSystem:setTexture]] ''sets a texture to particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:setTexture(texture,size) sets a texture to particles--> | [[b2.ParticleSystem:setTexture]] ''sets a texture to particles''<br/><!--GIDEROSMTD:b2.ParticleSystem:setTexture(texture,size) sets a texture to particles--> | ||
Latest revision as of 06:49, 8 November 2024
Supported platforms:
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)