Difference between revisions of "Particles:addParticles"
From GiderosMobile
(added example) |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | |||
<languages /> | <languages /> | ||
+ | |||
'''<translate>Available since</translate>:''' Gideros 2016.06<br/> | '''<translate>Available since</translate>:''' Gideros 2016.06<br/> | ||
'''<translate>Class</translate>:''' [[Special:MyLanguage/Particles|Particles]]<br/> | '''<translate>Class</translate>:''' [[Special:MyLanguage/Particles|Particles]]<br/> | ||
+ | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | <translate>Add particle a single particle (short form) or several ones (long form) to this particle system. | + | <translate> |
− | <br/> | + | Add particle a single particle (short form) or several ones (long form) to this particle system.<br/> |
− | Short form (single particle): | + | '''Short form''' (single particle): ''particles:addParticles(x,y,size,angle,ttl)''<br/> |
− | ''particles:addParticles(x,y,size,angle,ttl)'' | + | '''Extended form''': ''particles:addParticles{particleDesc1,particleDesc2,...,particleDescN}''<br/> |
− | <br/> | ||
− | Extended form: | ||
− | ''particles:addParticles{particleDesc1,particleDesc2,...,particleDescN}'' | ||
where particleDescX is a table describing a particle to be added. This table can contain the following parameters: | where particleDescX is a table describing a particle to be added. This table can contain the following parameters: | ||
<ul> | <ul> | ||
Line 22: | Line 22: | ||
<li>speedX,speedY,speedAngular,speedGrowth: Amount added to x,y,angle and size at the beginning of each frame</li> | <li>speedX,speedY,speedAngular,speedGrowth: Amount added to x,y,angle and size at the beginning of each frame</li> | ||
<li>decay,decayAngular,decayGrowth,decayAlpha: factor applied to speedX and speedY, speedAngular, speedGrowth and alpha at the beginning of each frame</li> | <li>decay,decayAngular,decayGrowth,decayAlpha: factor applied to speedX and speedY, speedAngular, speedGrowth and alpha at the beginning of each frame</li> | ||
− | </ul></translate> | + | </ul> |
+ | </translate> | ||
+ | <br/> | ||
+ | |||
<source lang="lua"> | <source lang="lua"> | ||
(number or table) = Particles:addParticles(particles) | (number or table) = Particles:addParticles(particles) | ||
</source> | </source> | ||
+ | <br/> | ||
+ | |||
+ | === <translate>Example</translate> === | ||
+ | '''Example:''': | ||
+ | <source lang="lua"> | ||
+ | local stars = Particles.new() | ||
+ | stars:setPosition(64, 64) | ||
+ | stage:addChild(stars) | ||
+ | stars:addParticles({ | ||
+ | {x=math.random(128*64),y=math.random(5*64),size=math.random(1,3),color=0xD9B589,ttl=30*60,speedX=0,speedY=0}, | ||
+ | {x=math.random(128*64),y=math.random(5*64),size=math.random(1,3),color=0xffff00,ttl=30*60,speedX=1,speedY=0}, | ||
+ | }) | ||
+ | </source> | ||
+ | |||
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
− | '''particles''': (table or arguments) <translate>table for multiple particles or arguments for single</translate> <br/> | + | '''particles''': (table or arguments) <translate>table for multiple particles or arguments for single</translate> |
+ | <br/> | ||
+ | |||
=== <translate>Return values</translate> === | === <translate>Return values</translate> === | ||
'''<translate>Returns</translate>''' (number or table) <translate>index or table with indexes of added particles</translate><br/> | '''<translate>Returns</translate>''' (number or table) <translate>index or table with indexes of added particles</translate><br/> | ||
+ | <br/> | ||
+ | <br/> |
Revision as of 01:22, 24 November 2019
Available since: Gideros 2016.06
Class: Particles
Description
Add particle a single particle (short form) or several ones (long form) to this particle system.
Short form (single particle): particles:addParticles(x,y,size,angle,ttl)
Extended form: particles:addParticles{particleDesc1,particleDesc2,...,particleDescN}
where particleDescX is a table describing a particle to be added. This table can contain the following parameters:
- x,y: particle position
- size: particle size
- angle: particle orientation
- color: particle color
- alpha: particle alpha
- ttl: time to leave, number of frames this particle will stay on screen
- tag: tag associated with this particle
- speedX,speedY,speedAngular,speedGrowth: Amount added to x,y,angle and size at the beginning of each frame
- decay,decayAngular,decayGrowth,decayAlpha: factor applied to speedX and speedY, speedAngular, speedGrowth and alpha at the beginning of each frame
(number or table) = Particles:addParticles(particles)
Example
Example::
local stars = Particles.new()
stars:setPosition(64, 64)
stage:addChild(stars)
stars:addParticles({
{x=math.random(128*64),y=math.random(5*64),size=math.random(1,3),color=0xD9B589,ttl=30*60,speedX=0,speedY=0},
{x=math.random(128*64),y=math.random(5*64),size=math.random(1,3),color=0xffff00,ttl=30*60,speedX=1,speedY=0},
})
Parameters
particles: (table or arguments) table for multiple particles or arguments for single
Return values
Returns (number or table) index or table with indexes of added particles