add particle to lua test

This commit is contained in:
yangxiao 2015-03-04 12:59:22 +08:00
parent b938872621
commit 6a6877b39f
1 changed files with 234 additions and 2 deletions

View File

@ -411,11 +411,238 @@ function Particle3DFlareShieldDemo:onExit()
self:unscheduleUpdate() self:unscheduleUpdate()
end end
-- Particle3DLightningBoltDemo
local Particle3DLightningBoltDemo = class("Particle3DLightningBolt", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DLightningBoltDemo:ctor()
-- body
self:init()
end
function Particle3DLightningBoltDemo:init()
baseInit(self)
end
function Particle3DLightningBoltDemo:title()
return "Particle3D Test"
end
function Particle3DLightningBoltDemo:subtitle()
return "LightningBolt"
end
function Particle3DLightningBoltDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("lightningBolt.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DLightningBoltDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DCanOfWormsDemo
local Particle3DCanOfWormsDemo = class("Particle3DCanOfWorms", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DCanOfWormsDemo:ctor()
-- body
self:init()
end
function Particle3DCanOfWormsDemo:init()
baseInit(self)
end
function Particle3DCanOfWormsDemo:title()
return "Particle3D Test"
end
function Particle3DCanOfWormsDemo:subtitle()
return "CanOfWorms"
end
function Particle3DCanOfWormsDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("canOfWorms.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DCanOfWormsDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DRibbonTrailDemo
local Particle3DRibbonTrailDemo = class("Particle3DRibbonTrail", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DRibbonTrailDemo:ctor()
-- body
self:init()
end
function Particle3DRibbonTrailDemo:init()
baseInit(self)
end
function Particle3DRibbonTrailDemo:title()
return "Particle3D Test"
end
function Particle3DRibbonTrailDemo:subtitle()
return "RibbonTrail"
end
function Particle3DRibbonTrailDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("ribbonTrailTest.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DRibbonTrailDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DWeaponTrailDemo
local Particle3DWeaponTrailDemo = class("Particle3DWeaponTrail", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DWeaponTrailDemo:ctor()
-- body
self:init()
end
function Particle3DWeaponTrailDemo:init()
baseInit(self)
end
function Particle3DWeaponTrailDemo:title()
return "Particle3D Test"
end
function Particle3DWeaponTrailDemo:subtitle()
return "WeaponTrail"
end
function Particle3DWeaponTrailDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("weaponTrail.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DWeaponTrailDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DExplosionSystemDemo
local Particle3DExplosionSystemDemo = class("Particle3DExplosionSystem", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DExplosionSystemDemo:ctor()
-- body
self:init()
end
function Particle3DExplosionSystemDemo:init()
baseInit(self)
end
function Particle3DExplosionSystemDemo:title()
return "Particle3D Test"
end
function Particle3DExplosionSystemDemo:subtitle()
return "ExplosionSystem"
end
function Particle3DExplosionSystemDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("explosionSystem.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DExplosionSystemDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DWithSprite3DDemo
local Particle3DWithSprite3DDemo = class("Particle3DWithSprite3D", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DWithSprite3DDemo:ctor()
-- body
self:init()
end
function Particle3DWithSprite3DDemo:init()
baseInit(self)
end
function Particle3DWithSprite3DDemo:title()
return "Particle3D Test"
end
function Particle3DWithSprite3DDemo:subtitle()
return "Particle3D With Sprite3D"
end
function Particle3DWithSprite3DDemo:onEnter()
local sprite = cc.Sprite3D:create("Sprite3DTest/orc.c3b")
sprite:setPosition3D(cc.vec3(-20, 0, 0))
sprite:setRotation3D(cc.vec3(0, 180, 0))
sprite:setCameraMask(cc.CameraFlag.USER1)
self:addChild(sprite)
local animation = cc.Animation3D:create("Sprite3DTest/orc.c3b")
local animate = cc.Animate3D:create(animation)
sprite:runAction(cc.RepeatForever:create(animate))
local billboard = cc.BillBoard:create("Images/Icon.png")
billboard:setPosition3D(cc.vec3(20, 0, 0))
billboard:setScale(0.2)
billboard:setCameraMask(cc.CameraFlag.USER1)
self:addChild(billboard)
local rootps = cc.PUParticleSystem3D:create("lineStreak.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DWithSprite3DDemo:onExit()
self:unscheduleUpdate()
end
function Particle3DTest() function Particle3DTest()
local scene = cc.Scene:create() local scene = cc.Scene:create()
Helper.createFunctionTable = Helper.createFunctionTable =
{ {
Particle3DExplosionSystemDemo.create,
Particle3DLineStreakDemo.create, Particle3DLineStreakDemo.create,
Particle3DBlackHoleDemo.create, Particle3DBlackHoleDemo.create,
Particle3DHypnoDemo.create, Particle3DHypnoDemo.create,
@ -424,10 +651,15 @@ function Particle3DTest()
Particle3DUVAnimDemo.create, Particle3DUVAnimDemo.create,
Particle3DFirePlaceDemo.create, Particle3DFirePlaceDemo.create,
Particle3DElectricBeamSystemDemo.create, Particle3DElectricBeamSystemDemo.create,
Particle3DFlareShieldDemo.create Particle3DFlareShieldDemo.create,
Particle3DLightningBoltDemo.create,
Particle3DCanOfWormsDemo.create,
Particle3DRibbonTrailDemo.create,
Particle3DWeaponTrailDemo.create,
Particle3DWithSprite3DDemo.create,
} }
scene:addChild(Particle3DLineStreakDemo.create()) scene:addChild(Particle3DExplosionSystemDemo.create())
scene:addChild(CreateBackMenuItem()) scene:addChild(CreateBackMenuItem())
return scene return scene