mirror of https://github.com/axmolengine/axmol.git
[ci skip]fix issue that can not change position style, can not add new emitter (#18272)
This commit is contained in:
parent
19962a3b59
commit
c4042c220b
|
@ -12,6 +12,8 @@ local baseLayer_entry = nil
|
|||
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
|
||||
local onEnterCallback = nil
|
||||
|
||||
local function backAction()
|
||||
SceneIdx = SceneIdx - 1
|
||||
if SceneIdx < 0 then
|
||||
|
@ -89,11 +91,14 @@ local function baseLayer_onEnterOrExit(tag)
|
|||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
if tag == "enter" then
|
||||
baseLayer_entry = scheduler:scheduleScriptFunc(update, 0, false)
|
||||
if onEnterCallback ~= nil then
|
||||
onEnterCallback()
|
||||
end
|
||||
elseif tag == "exit" then
|
||||
scheduler:unscheduleScriptEntry(baseLayer_entry)
|
||||
if emitter ~= nil then
|
||||
emitter:release()
|
||||
emitter = nil
|
||||
--emitter = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -228,13 +233,16 @@ local function ParticleReorder_onEnterOrExit(tag)
|
|||
if tag == "enter" then
|
||||
ParticleReorder_entry = scheduler:scheduleScriptFunc(reorderParticles, 1.0, false)
|
||||
elseif tag == "exit" then
|
||||
if ParticleReorder_entry ~= nil then
|
||||
scheduler:unscheduleScriptEntry(ParticleReorder_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ParticleReorder()
|
||||
ParticleReorder_layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
ParticleReorder_Order = 0
|
||||
ParticleReorder_layer:setColor(cc.c3b(0, 0, 0))
|
||||
ParticleReorder_layer:removeChild(background, true)
|
||||
|
@ -285,6 +293,8 @@ local function ParticleReorder()
|
|||
|
||||
titleLabel:setString("Reordering particles")
|
||||
subtitleLabel:setString("Reordering particles with and without batches batches")
|
||||
end
|
||||
|
||||
return ParticleReorder_layer
|
||||
end
|
||||
|
||||
|
@ -320,7 +330,9 @@ local function ParticleBatchHybrid_onEnterOrExit(tag)
|
|||
if tag == "enter" then
|
||||
ParticleBatchHybrid_entry = scheduler:scheduleScriptFunc(switchRender, 2.0, false)
|
||||
elseif tag == "exit" then
|
||||
if ParticleBatchHybrid_entry ~= nil then
|
||||
scheduler:unscheduleScriptEntry(ParticleBatchHybrid_entry)
|
||||
end
|
||||
if nil ~= emitter then
|
||||
emitter:release()
|
||||
emitter = nil
|
||||
|
@ -331,6 +343,7 @@ end
|
|||
local function ParticleBatchHybrid()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -350,6 +363,8 @@ local function ParticleBatchHybrid()
|
|||
|
||||
titleLabel:setString("Particle Batch")
|
||||
subtitleLabel:setString("Hybrid: batched and non batched every 2 seconds")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -359,6 +374,7 @@ end
|
|||
local function ParticleBatchMultipleEmitters()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -384,6 +400,8 @@ local function ParticleBatchMultipleEmitters()
|
|||
|
||||
titleLabel:setString("Particle Batch")
|
||||
subtitleLabel:setString("Multiple emitters. One Batch")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -393,14 +411,16 @@ end
|
|||
local function DemoFlower()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function()
|
||||
emitter = cc.ParticleFlower:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
emitter:setTexture(cc.Director:getInstance():getTextureCache():addImage(s_stars1))
|
||||
|
||||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleFlower")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -410,6 +430,7 @@ end
|
|||
local function DemoGalaxy()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleGalaxy:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -419,6 +440,8 @@ local function DemoGalaxy()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleGalaxy")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -428,6 +451,7 @@ end
|
|||
local function DemoFirework()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleFireworks:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -437,6 +461,8 @@ local function DemoFirework()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleFireworks")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -446,6 +472,7 @@ end
|
|||
local function DemoSpiral()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSpiral:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -455,6 +482,8 @@ local function DemoSpiral()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleSpiral")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -464,6 +493,7 @@ end
|
|||
local function DemoSun()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSun:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -473,6 +503,8 @@ local function DemoSun()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleSun")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -481,6 +513,8 @@ end
|
|||
---------------------------------
|
||||
local function DemoPause()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSmoke:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -490,6 +524,8 @@ local layer = getBaseLayer()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("Pasue Particle")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -499,6 +535,7 @@ end
|
|||
local function DemoMeteor()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleMeteor:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -508,6 +545,8 @@ local function DemoMeteor()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleMeteor")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -517,6 +556,7 @@ end
|
|||
local function DemoFire()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleFire:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -526,6 +566,8 @@ local function DemoFire()
|
|||
emitter:setPosition(pos_x, 100)
|
||||
|
||||
titleLabel:setString("ParticleFire")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -535,6 +577,7 @@ end
|
|||
local function DemoSmoke()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSmoke:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -545,6 +588,8 @@ local function DemoSmoke()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleSmoke")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -554,6 +599,7 @@ end
|
|||
local function DemoExplosion()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleExplosion:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -565,6 +611,8 @@ local function DemoExplosion()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleExplosion")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -574,6 +622,7 @@ end
|
|||
local function DemoSnow()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSnow:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -606,6 +655,8 @@ local function DemoSnow()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleSnow")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -615,6 +666,7 @@ end
|
|||
local function DemoRain()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleRain:create()
|
||||
emitter:retain()
|
||||
background:addChild(emitter, 10)
|
||||
|
@ -627,6 +679,8 @@ local function DemoRain()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleRain")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -636,6 +690,7 @@ end
|
|||
local function DemoBigFlower()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSystemQuad:createWithTotalParticles(50)
|
||||
emitter:retain()
|
||||
|
||||
|
@ -696,6 +751,8 @@ local function DemoBigFlower()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleBigFlower")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -705,6 +762,7 @@ end
|
|||
local function DemoRotFlower()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSystemQuad:createWithTotalParticles(300)
|
||||
emitter:retain()
|
||||
|
||||
|
@ -768,6 +826,8 @@ local function DemoRotFlower()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("ParticleRotFlower")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -777,6 +837,7 @@ end
|
|||
local function DemoModernArt()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleSystemQuad:createWithTotalParticles(1000)
|
||||
emitter:retain()
|
||||
|
||||
|
@ -837,6 +898,8 @@ local function DemoModernArt()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("Varying size")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -846,6 +909,7 @@ end
|
|||
local function DemoRing()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
emitter = cc.ParticleFlower:create()
|
||||
emitter:retain()
|
||||
|
||||
|
@ -861,6 +925,8 @@ local function DemoRing()
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString("Ring Demo")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -870,6 +936,7 @@ end
|
|||
local function ParallaxParticle()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
background:getParent():removeChild(background, true)
|
||||
background = nil
|
||||
|
||||
|
@ -899,6 +966,8 @@ local function ParallaxParticle()
|
|||
p:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
titleLabel:setString("Parallax + Particles")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -908,6 +977,7 @@ end
|
|||
local function DemoParticleFromFile(name)
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -921,6 +991,8 @@ local function DemoParticleFromFile(name)
|
|||
setEmitterPosition()
|
||||
|
||||
titleLabel:setString(name)
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -930,6 +1002,7 @@ end
|
|||
local function RadiusMode1()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -993,6 +1066,8 @@ local function RadiusMode1()
|
|||
emitter:setBlendAdditive(false)
|
||||
|
||||
titleLabel:setString("Radius Mode: Spiral")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1002,6 +1077,7 @@ end
|
|||
local function RadiusMode2()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1064,6 +1140,8 @@ local function RadiusMode2()
|
|||
emitter:setBlendAdditive(false)
|
||||
|
||||
titleLabel:setString("Radius Mode: Semi Circle")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1073,6 +1151,7 @@ end
|
|||
local function Issue704()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1140,6 +1219,8 @@ local function Issue704()
|
|||
|
||||
titleLabel:setString("Issue 704. Free + Rot")
|
||||
subtitleLabel:setString("Emitted particles should not rotate")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1162,17 +1243,19 @@ local function Issue870_onEnterOrExit(tag)
|
|||
if tag == "enter" then
|
||||
Issue870_entry = scheduler:scheduleScriptFunc(updateQuads, 2.0, false)
|
||||
elseif tag == "exit" then
|
||||
if Issue870_entry ~= nil then
|
||||
scheduler:unscheduleScriptEntry(Issue870_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function Issue870()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
||||
local system = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist")
|
||||
system:setTextureWithRect(cc.Director:getInstance():getTextureCache():addImage("Images/particles.png"), cc.rect(0,0,32,32))
|
||||
layer:addChild(system, 10)
|
||||
|
@ -1184,6 +1267,8 @@ local function Issue870()
|
|||
|
||||
titleLabel:setString("Issue 870. SubRect")
|
||||
subtitleLabel:setString("Every 2 seconds the particle should change")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1193,6 +1278,7 @@ end
|
|||
local function MultipleParticleSystems()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1210,6 +1296,8 @@ local function MultipleParticleSystems()
|
|||
|
||||
titleLabel:setString("Multiple particle systems")
|
||||
subtitleLabel:setString("v1.1 test: FPS should be lower than next test")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1219,6 +1307,7 @@ end
|
|||
local function MultipleParticleSystemsBatched()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1238,6 +1327,8 @@ local function MultipleParticleSystemsBatched()
|
|||
|
||||
titleLabel:setString("Multiple particle systems batched")
|
||||
subtitleLabel:setString("v1.1 test: should perform better than previous test")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1274,13 +1365,16 @@ local function AddAndDeleteParticleSystems_onEnterOrExit(tag)
|
|||
if tag == "enter" then
|
||||
AddAndDeleteParticleSystems_entry = scheduler:scheduleScriptFunc(removeSystem, 2.0, false)
|
||||
elseif tag == "exit" then
|
||||
if AddAndDeleteParticleSystems_entry ~= nil then
|
||||
scheduler:unscheduleScriptEntry(AddAndDeleteParticleSystems_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function AddAndDeleteParticleSystems()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1308,6 +1402,8 @@ local function AddAndDeleteParticleSystems()
|
|||
|
||||
titleLabel:setString("Add and remove Particle System")
|
||||
subtitleLabel:setString("v1.1 test: every 2 sec 1 system disappear, 1 appears")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1334,13 +1430,16 @@ local function ReorderParticleSystems_onEnterOrExit(tag)
|
|||
if tag == "enter" then
|
||||
ReorderParticleSystems_entry = scheduler:scheduleScriptFunc(reorderSystem, 2.0, false)
|
||||
elseif tag == "exit" then
|
||||
if ReorderParticleSystems_entry ~= nil then
|
||||
scheduler:unscheduleScriptEntry(ReorderParticleSystems_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ReorderParticleSystems()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background ,true)
|
||||
background = nil
|
||||
|
@ -1424,6 +1523,8 @@ local function ReorderParticleSystems()
|
|||
|
||||
titleLabel:setString("reorder systems")
|
||||
subtitleLabel:setString("changes every 2 seconds")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1433,6 +1534,7 @@ end
|
|||
local function PremultipliedAlphaTest()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 255))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1453,6 +1555,8 @@ local function PremultipliedAlphaTest()
|
|||
|
||||
titleLabel:setString("premultiplied alpha")
|
||||
subtitleLabel:setString("no black halo, particles should fade out")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
@ -1462,6 +1566,7 @@ end
|
|||
local function PremultipliedAlphaTest2()
|
||||
local layer = getBaseLayer()
|
||||
|
||||
onEnterCallback = function ()
|
||||
layer:setColor(cc.c3b(0, 0, 0))
|
||||
layer:removeChild(background, true)
|
||||
background = nil
|
||||
|
@ -1472,6 +1577,8 @@ local function PremultipliedAlphaTest2()
|
|||
|
||||
titleLabel:setString("premultiplied alpha 2")
|
||||
subtitleLabel:setString("Arrows should be faded")
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue