当前位置:网站首页>cocos2dx_ Lua particle system

cocos2dx_ Lua particle system

2022-07-05 04:56:00 Meteor spot

-- A shooting star
    local meteor = cc.ParticleMeteor:createWithTotalParticles(130)
   -- meteor:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))
    meteor:setPosition(cc.p( 250, 200))
    meteor:setLocalZOrder(9999)
    meteor:setLife(5.0)
    self:addChild(meteor)
     -- rain
    local rain = cc.ParticleRain:createWithTotalParticles(130)
   --  rain:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    rain:setPosition(cc.p( 300, 200))
    rain:setLocalZOrder(9999)
    rain:setLife(5.0)
    self:addChild(rain)
 
    -- snow
    local snow = cc.ParticleSnow:createWithTotalParticles(130)
  --   snow:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    snow:setPosition(cc.p( 350, 200))
    snow:setLocalZOrder(9999)
    snow:setLife(5.0)
    self:addChild(snow)
 -- The explosion
    local explosion = cc.ParticleExplosion:createWithTotalParticles(130)
  --   explosion:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    explosion:setPosition(cc.p( 350, 200))
    explosion:setLocalZOrder(9999)
    explosion:setLife(5.0)
    self:addChild(explosion)
    
-- smoke
    local smoke = cc.ParticleSmoke:createWithTotalParticles(130)
     --  smoke:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    smoke:setPosition(cc.p( 350, 200))
    smoke:setLocalZOrder(9999)
    smoke:setLife(5.0)
    self:addChild(smoke)
 
    -- Whirlpool
    local spiral = cc.ParticleSpiral:createWithTotalParticles(130)
    --   spiral:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    spiral:setPosition(cc.p( 450, 200))
    spiral:setLocalZOrder(9999)
    spiral:setLife(5.0)
    self:addChild(spiral)
  local sun = cc.ParticleSun:createWithTotalParticles(130)
   -- sun:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    sun:setPosition(cc.p( 500, 200))
    sun:setLocalZOrder(9999)
    sun:setLife(1.0)
    self:addChild(sun)
 
   local fire = cc.ParticleFire:createWithTotalParticles(130)
    --fire:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    fire:setPosition(cc.p( 550, 200))
    fire:setLocalZOrder(9999)
    fire:setLife(1.0)
    self:addChild(fire)
 local fireworks = cc.ParticleFireworks:createWithTotalParticles(50)
--fireworks:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    fireworks:setPosition(cc.p( 550, 200))
    fireworks:setLocalZOrder(9999)
    fireworks:setLife(1.0)
    self:addChild(fireworks)
    local galaxy = cc.ParticleGalaxy:createWithTotalParticles(130)
    --galaxy:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    galaxy:setPosition(cc.p( 550, 200))
    galaxy:setLocalZOrder(9999)
    galaxy:setLife(1.0)
    self:addChild(galaxy)
     local flower = cc.ParticleFlower:createWithTotalParticles(130)
     --  flower:setTexture(cc.Director:getInstance():getTextureCache():addImage("wsk1.png"))

    flower:setPosition(cc.p( 600, 200))
    flower:setLocalZOrder(9999)
    flower:setLife(1.0)
    self:addChild(flower)

Load custom particle effects
    local  particleSystem = cc.ParticleSystemQuad:create("lobby/Desktop.plist");
    particleSystem:setPosition(cc.p(500,300));
    layer:addChild(particleSystem)
 

原网站

版权声明
本文为[Meteor spot]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140625237887.html