Difference between revisions of "Particles"
(case harmonisation) |
(added example) |
||
| Line 7: | Line 7: | ||
=== Description === | === Description === | ||
A particle system which allows to draw several identical dots or bitmaps, with varying colour and orientation. | A particle system which allows to draw several identical dots or bitmaps, with varying colour and orientation. | ||
| + | |||
| + | === Example === | ||
| + | <source lang="lua"> | ||
| + | -- gideros particles | ||
| + | local particleGFX = Texture.new("gfx/fx/smoke.png") | ||
| + | local stars = Particles.new() | ||
| + | stars:setTexture(particleGFX) | ||
| + | stage:addChild(stars) | ||
| + | stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) | ||
| + | |||
| + | -- GAME LOOP | ||
| + | function onEnterFrame(e) | ||
| + | if (e.time // 1) % 2 == 0 then | ||
| + | self.stars:addParticles({ | ||
| + | { | ||
| + | x=math.random(480),y=math.random(320), | ||
| + | size=32,angle=math.random(360), | ||
| + | color=0xffffff,alpha=0.2, | ||
| + | ttl=16*64, | ||
| + | speedX=0.01,speedY=0.01,speedAngular=0.15, | ||
| + | speedGrowth=0.5, | ||
| + | }, | ||
| + | { | ||
| + | x=math.random(480),y=math.random(320), | ||
| + | size=24,angle=math.random(360/2), | ||
| + | color=0x0,alpha=0.2, | ||
| + | ttl=8*64, | ||
| + | speedX=0.01,speedY=0.01,speedAngular=0.015, | ||
| + | speedGrowth=0.5, | ||
| + | }, | ||
| + | }) | ||
| + | end | ||
| + | end | ||
| + | </source> | ||
{|- | {|- | ||
Revision as of 23:39, 2 August 2021
Supported platforms: ![]()
![]()
![]()
![]()
![]()
![]()
![]()
Available since: Gideros 2016.06
Inherits from: Sprite
Description
A particle system which allows to draw several identical dots or bitmaps, with varying colour and orientation.
Example
-- gideros particles
local particleGFX = Texture.new("gfx/fx/smoke.png")
local stars = Particles.new()
stars:setTexture(particleGFX)
stage:addChild(stars)
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
-- GAME LOOP
function onEnterFrame(e)
if (e.time // 1) % 2 == 0 then
self.stars:addParticles({
{
x=math.random(480),y=math.random(320),
size=32,angle=math.random(360),
color=0xffffff,alpha=0.2,
ttl=16*64,
speedX=0.01,speedY=0.01,speedAngular=0.15,
speedGrowth=0.5,
},
{
x=math.random(480),y=math.random(320),
size=24,angle=math.random(360/2),
color=0x0,alpha=0.2,
ttl=8*64,
speedX=0.01,speedY=0.01,speedAngular=0.015,
speedGrowth=0.5,
},
})
end
end
MethodsParticles.new creates new particles group |
EventsConstants |