--// Local auxiliary functions - - - - - - - - - - - - - - - - - - - - - - - -

--// 1.	rename:					" -> '
--// 2. comment root composition routine "createCompositionBG_Candle_cave = function()"
--// 3. add auxiliaru routines for managing animations: 
--		auxPlayCandleCaveAnimation(), 
--		auxGetCandleCaveAnimation(), 
--		auxCreateCandleCaveAnimations()
--// 4. replace CreateCompositionElement() with auxCreateCompositionElement() for some corrections ...

------------------------------------------------------------------------------
--
function auxPlayCandleCaveAnimation(compositionName)
    local composition = auxGetCandleCaveAnimation(compositionName);
    composition:SetVisible(true);
    composition:Play();
end

------------------------------------------------------------------------------
--
function auxHideCandleCaveAnimation(compositionName)
    local composition = auxGetCandleCaveAnimation(compositionName);
    composition:Stop();
    composition:SetVisible(false);
end

------------------------------------------------------------------------------
--
function auxGetCandleCaveAnimation(compositionName)
    assert(candleCaveCompositions ~= nil and compositionName ~= nil);
	assert(candleCaveCompositions[compositionName] ~= nil and 'Composition with specified name not exists !');

    return candleCaveCompositions[compositionName];
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--

function CreateComposition(parent, compositionRoutine, name, x,y,z, hotSpotX,hotSpotY, duration, isCyclic)
    assert(parent ~= nil and compositionRoutine ~= nil and name ~= nil and z ~= nil and duration ~= nil);

    local element = compositionRoutine();
    element:SetName(name);
    element:SetHotSpot(hotSpotX,hotSpotY);
    element:SetXY(x, y);
    assert(z - parent:GetZ());
    element:SetZ(z - parent:GetZ());
    element:AttachTo(parent);

    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    element:SetOpacity(1);
    
    if (isCyclic == true) then
        element:SetDuration(duration);
        element:SetCyclic(true);
    end
	element:Stop();
    element:SetVisible(false);
    element:AssignClippingRect(parent);
	element:SetConsiderParentOpacity(true);

	return element;
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxCreateCompositionElement(resourceName)
	local element = CreateCompositionElement(resourceName);
    local texName = string.sub(resourceName, string.len('data/Texture/Scenes/17_CandleCave/Animations/Env') + 1);

    --// set up blend mode for sprites with additive blending
--	if (texName == '.jpg') then
--		element:GetTexture():SetColor('0xBBFFFFFF');
        element:GetTexture():SetBlendMode(0);
--    end
	return element;
end

------------------------------------------------------------------------------
--
function auxCreateCandleCaveAnimations(parent)
    assert(parent ~= nil);
    candleCaveCompositions = {};
    local CreateAndRegisterComposition = function (parent, compositionRoutine, name, x,y,z, hotSpotX,hotSpotY, duration, isCyclic)
        local element = CreateComposition(parent, compositionRoutine, name, x,y,z, hotSpotX,hotSpotY, duration, isCyclic);
        candleCaveCompositions[element:GetName()] = element;
    end
    
    CreateAndRegisterComposition(parent, createCompositionfrontEnv,   	'FrontEnv',  		0,0,102.0, 512,384, 10, true);
    CreateAndRegisterComposition(parent, createCompositionfronForceField,'FrontForceField',	0,0,102.0, 512,384, 10, true);
    CreateAndRegisterComposition(parent, createCompositionbackEnv,		'BackEnv', 			0,0,102.0, 512,384, 10, true);
    CreateAndRegisterComposition(parent, createCompositionbackForceField,'BackForceField',	0,0,102.0, 512,384, 10, true);
end

------------------------------------------------------------------------------
--
--createCompositionBG_Candle_cave = function()
--
--    local compositionBG_Candle_cave = CreateCompositionSequence();
--    local compositionDuration = 10;
--    compositionBG_Candle_cave:SetDuration(compositionDuration);
--
--
--    -- Layer Layer_1
--    local element = createCompositionfrontEnv();
--    element:SetName('Layer_1');
--    compositionBG_Candle_cave:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBG_Candle_cave);
--    element:SetXY(512, 384);
--
--    element:SetScaleX(1);
--    element:SetScaleY(1);
--    element:SetAngle(0);
--    element:SetOpacity(1);
--
--    effector = element:GetEffector();
--    effector:SetLifeTime(0, 10);
--
--
--    effector:Play();
--
--
--    -- Layer Layer_2
--    local element = createCompositionfronForceField();
--    element:SetName('Layer_2');
--    compositionBG_Candle_cave:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBG_Candle_cave);
--    element:SetXY(512, 384);
--
--    element:SetScaleX(1);
--    element:SetScaleY(1);
--    element:SetAngle(0);
--    element:SetOpacity(1);
--
--    effector = element:GetEffector();
--    effector:SetLifeTime(0, 10);
--
--
--    effector:Play();
--
--
--    -- Layer Layer_3
--    local element = createCompositionbackEnv();
--    element:SetName('Layer_3');
--    compositionBG_Candle_cave:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBG_Candle_cave);
--    element:SetXY(512, 384);
--
--    element:SetScaleX(1);
--    element:SetScaleY(1);
--    element:SetAngle(0);
--    element:SetOpacity(1);
--
--    effector = element:GetEffector();
--    effector:SetLifeTime(0, 10);
--
--
--    effector:Play();
--
--
--    -- Layer Layer_4
--    local element = createCompositionbackForceField();
--    element:SetName('Layer_4');
--    compositionBG_Candle_cave:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBG_Candle_cave);
--    element:SetXY(512, 384);
--
--    element:SetScaleX(1);
--    element:SetScaleY(1);
--    element:SetAngle(0);
--    element:SetOpacity(1);
--
--    effector = element:GetEffector();
--    effector:SetLifeTime(0, 10);
--
--
--    effector:Play();
--
--
--    -- Layer ...
--
--    compositionBG_Candle_cave:Play();
--
--    return compositionBG_Candle_cave;
--end

createCompositionbackEnv = function()

    local compositionbackEnv = CreateCompositionSequence();
    local compositionDuration = 10;
    compositionbackEnv:SetDuration(compositionDuration);


    -- Layer Layer_1
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_light2_01.jpg');
    element:SetName('Layer_1');
    compositionbackEnv:AddElement(element);
    element:SetHotSpot(64, 61.5);
    element:SetParentElement(compositionbackEnv);
    element:SetXY(754.162155151367, 499.315338134766);

    element:SetScaleX(3);
    element:SetScaleY(3);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_O, 0, 0.1);
    effector:SetKey(_TRACK_O, 0.52, 0.2);
    effector:SetKey(_TRACK_O, 1.12, 0.05);
    effector:SetKey(_TRACK_O, 1.88, 0.4);
    effector:SetKey(_TRACK_O, 2.64, 0.2);
    effector:SetKey(_TRACK_O, 3.44, 0.3);
    effector:SetKey(_TRACK_O, 4.24, 0.05);
    effector:SetKey(_TRACK_O, 5.2, 0.45);
    effector:SetKey(_TRACK_O, 5.76, 0.2);
    effector:SetKey(_TRACK_O, 6.32, 0.25);
    effector:SetKey(_TRACK_O, 7.08, 0.05);
    effector:SetKey(_TRACK_O, 7.8, 0.25);
    effector:SetKey(_TRACK_O, 8.52, 0.05);
    effector:SetKey(_TRACK_O, 9.96, 0.1);

    effector:Play();


    -- Layer Layer_2
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_light2_01.jpg');
    element:SetName('Layer_2');
    compositionbackEnv:AddElement(element);
    element:SetHotSpot(64, 61.5);
    element:SetParentElement(compositionbackEnv);
    element:SetXY(892.54052734375, 438.198226928711);

    element:SetScaleX(3);
    element:SetScaleY(3);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_O, 0, 0.1);
    effector:SetKey(_TRACK_O, 1.24, 0.2);
    effector:SetKey(_TRACK_O, 1.84, 0.05);
    effector:SetKey(_TRACK_O, 2.6, 0.4);
    effector:SetKey(_TRACK_O, 3.36, 0.2);
    effector:SetKey(_TRACK_O, 4.16, 0.3);
    effector:SetKey(_TRACK_O, 4.96, 0.05);
    effector:SetKey(_TRACK_O, 6.08, 0.45);
    effector:SetKey(_TRACK_O, 6.64, 0.2);
    effector:SetKey(_TRACK_O, 7.2, 0.25);
    effector:SetKey(_TRACK_O, 7.96, 0.05);
    effector:SetKey(_TRACK_O, 8.68, 0.25);
    effector:SetKey(_TRACK_O, 9.4, 0.05);
    effector:SetKey(_TRACK_O, 9.96, 0.1);

    effector:Play();


    -- Layer Layer_3
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_light2_01.jpg');
    element:SetName('Layer_3');
    compositionbackEnv:AddElement(element);
    element:SetHotSpot(64, 61.5);
    element:SetParentElement(compositionbackEnv);
    element:SetXY(1015.92791748047, 358.630661010742);

    element:SetScaleX(3);
    element:SetScaleY(3);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_O, 0, 0.1);
    effector:SetKey(_TRACK_O, 0.76, 0.05);
    effector:SetKey(_TRACK_O, 1.72, 0.2);
    effector:SetKey(_TRACK_O, 2.32, 0.05);
    effector:SetKey(_TRACK_O, 3.08, 0.4);
    effector:SetKey(_TRACK_O, 3.84, 0.2);
    effector:SetKey(_TRACK_O, 4.64, 0.3);
    effector:SetKey(_TRACK_O, 5.44, 0.05);
    effector:SetKey(_TRACK_O, 6.56, 0.45);
    effector:SetKey(_TRACK_O, 7.12, 0.2);
    effector:SetKey(_TRACK_O, 7.68, 0.25);
    effector:SetKey(_TRACK_O, 8.44, 0.05);
    effector:SetKey(_TRACK_O, 9.16, 0.25);
    effector:SetKey(_TRACK_O, 9.96, 0.1);

    effector:Play();

    compositionbackEnv:Play();

    return compositionbackEnv;
end

createCompositionbackForceField = function()

    local compositionbackForceField = CreateCompositionSequence();
    local compositionDuration = 10;
    compositionbackForceField:SetDuration(compositionDuration);


    -- Layer Layer_4
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Lightning01.jpg');
    element:SetName('Layer_4');
    compositionbackForceField:AddElement(element);
    element:SetHotSpot(64.5, 147);
    element:SetParentElement(compositionbackForceField);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 719.567565917969);
    effector:SetKey(_TRACK_Y, 0, 111.855850219727);
    effector:SetKey(_TRACK_X, 1.12, 719.567565917969);
    effector:SetKey(_TRACK_Y, 1.12, 111.855850219727);
    effector:SetKey(_TRACK_X, 1.24, 719.567565917969);
    effector:SetKey(_TRACK_Y, 1.24, 111.855850219727);
    effector:SetKey(_TRACK_X, 1.52, 675.747741699219);
    effector:SetKey(_TRACK_Y, 1.52, 99.1711730957031);
    effector:SetKey(_TRACK_X, 1.88, 636.540542602539);
    effector:SetKey(_TRACK_Y, 1.88, 88.7927856445313);
    effector:SetKey(_TRACK_X, 2.04, 636.540542602539);
    effector:SetKey(_TRACK_Y, 2.04, 88.7927856445313);
    effector:SetKey(_TRACK_X, 2.48, 719.567565917969);
    effector:SetKey(_TRACK_Y, 2.48, 92.2522430419922);
    effector:SetKey(_TRACK_X, 5.32, 719.567565917969);
    effector:SetKey(_TRACK_Y, 5.32, 111.855850219727);
    effector:SetKey(_TRACK_X, 5.44, 719.567565917969);
    effector:SetKey(_TRACK_Y, 5.44, 111.855850219727);
    effector:SetKey(_TRACK_X, 5.72, 675.747741699219);
    effector:SetKey(_TRACK_Y, 5.72, 99.1711730957031);
    effector:SetKey(_TRACK_X, 7.88, 636.540542602539);
    effector:SetKey(_TRACK_Y, 7.88, 88.7927856445313);
    effector:SetKey(_TRACK_X, 8.32, 676.900894165039);
    effector:SetKey(_TRACK_Y, 8.32, 74.9549407958984);
    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 1.12, 0.62455478734548);
    effector:SetKey(_TRACK_SY, 1.12, 0.94508794508794);
    effector:SetKey(_TRACK_SX, 1.28, 1.1);
    effector:SetKey(_TRACK_SY, 1.28, 1.1);
    effector:SetKey(_TRACK_SX, 1.32, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 1.32, 1.1);
    effector:SetKey(_TRACK_SX, 1.4, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 1.4, 1.1);
    effector:SetKey(_TRACK_SX, 1.44, 1.24302674767791);
    effector:SetKey(_TRACK_SY, 1.44, 1.23335784764356);
    effector:SetKey(_TRACK_SX, 1.76, 1.24302674767791);
    effector:SetKey(_TRACK_SY, 1.76, 1.23335784764356);
    effector:SetKey(_TRACK_SX, 1.88, 0.4457713527481);
    effector:SetKey(_TRACK_SY, 1.88, 0.81173009744438);
    effector:SetKey(_TRACK_SX, 2.04, 0.59940638312731);
    effector:SetKey(_TRACK_SY, 2.04, 1.17060121345836);
    effector:SetKey(_TRACK_SX, 2.08, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 2.08, 1.1);
    effector:SetKey(_TRACK_SX, 2.16, -1.06327955862839);
    effector:SetKey(_TRACK_SY, 2.16, 0.65285898143041);
    effector:SetKey(_TRACK_SX, 2.2, 1.24302674767791);
    effector:SetKey(_TRACK_SY, 2.2, 1.23335784764356);
    effector:SetKey(_TRACK_SX, 2.28, 0.76233156233156);
    effector:SetKey(_TRACK_SY, 2.28, 1.39854705568991);
    effector:SetKey(_TRACK_SX, 5.32, 0.62455478734548);
    effector:SetKey(_TRACK_SY, 5.32, 0.94508794508794);
    effector:SetKey(_TRACK_SX, 5.48, 1.1);
    effector:SetKey(_TRACK_SY, 5.48, 1.1);
    effector:SetKey(_TRACK_SX, 5.52, -0.86661778057127);
    effector:SetKey(_TRACK_SY, 5.52, 0.77837224980082);
    effector:SetKey(_TRACK_SX, 5.6, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 5.6, 1.1);
    effector:SetKey(_TRACK_SX, 5.64, 1.24302674767791);
    effector:SetKey(_TRACK_SY, 5.64, 1.23335784764356);
    effector:SetKey(_TRACK_SX, 7.88, 0.4457713527481);
    effector:SetKey(_TRACK_SY, 7.88, 0.81173009744438);
    effector:SetKey(_TRACK_SX, 8.04, 1.1);
    effector:SetKey(_TRACK_SY, 8.04, 1.1);
    effector:SetKey(_TRACK_SX, 8.08, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 8.08, 1.1);
    effector:SetKey(_TRACK_SX, 8.16, -1.02752287170892);
    effector:SetKey(_TRACK_SY, 8.16, 1.1);
    effector:SetKey(_TRACK_SX, 8.2, 1.24302674767791);
    effector:SetKey(_TRACK_SY, 8.2, 1.23335784764356);
    effector:SetKey(_TRACK_SX, 8.32, 0.97485159578183);
    effector:SetKey(_TRACK_SY, 8.32, 1.6412759698474);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 1.08, 0);
    effector:SetKey(_TRACK_O, 1.12, 1);
    effector:SetKey(_TRACK_O, 1.28, 0);
    effector:SetKey(_TRACK_O, 1.36, 1);
    effector:SetKey(_TRACK_O, 1.44, 0.2);
    effector:SetKey(_TRACK_O, 1.52, 1);
    effector:SetKey(_TRACK_O, 1.68, 0);
    effector:SetKey(_TRACK_O, 1.84, 0);
    effector:SetKey(_TRACK_O, 1.88, 1);
    effector:SetKey(_TRACK_O, 2.04, 0);
    effector:SetKey(_TRACK_O, 2.12, 1);
    effector:SetKey(_TRACK_O, 2.2, 0.2);
    effector:SetKey(_TRACK_O, 2.28, 1);
    effector:SetKey(_TRACK_O, 2.44, 0);
    effector:SetKey(_TRACK_O, 5.28, 0);
    effector:SetKey(_TRACK_O, 5.32, 1);
    effector:SetKey(_TRACK_O, 5.48, 0);
    effector:SetKey(_TRACK_O, 5.56, 1);
    effector:SetKey(_TRACK_O, 5.64, 0.2);
    effector:SetKey(_TRACK_O, 5.72, 1);
    effector:SetKey(_TRACK_O, 5.88, 0);
    effector:SetKey(_TRACK_O, 7.84, 0);
    effector:SetKey(_TRACK_O, 7.88, 1);
    effector:SetKey(_TRACK_O, 8.04, 0);
    effector:SetKey(_TRACK_O, 8.12, 1);
    effector:SetKey(_TRACK_O, 8.2, 0.2);
    effector:SetKey(_TRACK_O, 8.28, 1);
    effector:SetKey(_TRACK_O, 8.44, 0);

    effector:Play();


    -- Layer Layer_5
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Sparcle01.jpg');
    element:SetName('Layer_5');
    compositionbackForceField:AddElement(element);
    element:SetHotSpot(64, 57);
    element:SetParentElement(compositionbackForceField);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 678.126129150391);
    effector:SetKey(_TRACK_Y, 0, 132.837844848633);
    effector:SetKey(_TRACK_X, 1.16, 677.126129150391);
    effector:SetKey(_TRACK_Y, 1.16, 49.8378448486328);
    effector:SetKey(_TRACK_X, 1.64, 678.126129150391);
    effector:SetKey(_TRACK_Y, 1.64, 132.837844848633);
    effector:SetKey(_TRACK_X, 2.435625, 677.126129150391);
    effector:SetKey(_TRACK_Y, 2.435625, 49.8378448486328);
    effector:SetKey(_TRACK_X, 2.9522265625, 678.126129150391);
    effector:SetKey(_TRACK_Y, 2.9522265625, 132.837844848633);
    effector:SetKey(_TRACK_X, 4.557578125, 677.126129150391);
    effector:SetKey(_TRACK_Y, 4.557578125, 49.8378448486328);
    effector:SetKey(_TRACK_X, 5.362421875, 678.126129150391);
    effector:SetKey(_TRACK_Y, 5.362421875, 132.837844848633);
    effector:SetKey(_TRACK_X, 6.522421875, 677.126129150391);
    effector:SetKey(_TRACK_Y, 6.522421875, 49.8378448486328);
    effector:SetKey(_TRACK_X, 7.002421875, 678.126129150391);
    effector:SetKey(_TRACK_Y, 7.002421875, 132.837844848633);
    effector:SetKey(_TRACK_X, 7.798046875, 677.126129150391);
    effector:SetKey(_TRACK_Y, 7.798046875, 49.8378448486328);
    effector:SetKey(_TRACK_X, 8.3146484375, 678.126129150391);
    effector:SetKey(_TRACK_Y, 8.3146484375, 132.837844848633);
    effector:SetKey(_TRACK_X, 9.92, 677.126129150391);
    effector:SetKey(_TRACK_Y, 9.92, 49.8378448486328);
    effector:SetKey(_TRACK_SX, 0, 0.84375);
    effector:SetKey(_TRACK_SY, 0, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 0.68, 0.953125);
    effector:SetKey(_TRACK_SY, 0.68, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 1.16, 0.84375);
    effector:SetKey(_TRACK_SY, 1.16, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 1.64, 0.84375);
    effector:SetKey(_TRACK_SY, 1.64, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 2.96, 0.84375);
    effector:SetKey(_TRACK_SY, 2.96, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 4.56, 0.84375);
    effector:SetKey(_TRACK_SY, 4.56, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 5.362421875, 0.84375);
    effector:SetKey(_TRACK_SY, 5.362421875, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 6.042421875, 0.953125);
    effector:SetKey(_TRACK_SY, 6.042421875, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 6.522421875, 0.84375);
    effector:SetKey(_TRACK_SY, 6.522421875, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 7.002421875, 0.84375);
    effector:SetKey(_TRACK_SY, 7.002421875, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 8.322421875, 0.84375);
    effector:SetKey(_TRACK_SY, 8.322421875, 1.80701754385965);
    effector:SetKey(_TRACK_SX, 9.922421875, 0.84375);
    effector:SetKey(_TRACK_SY, 9.922421875, 1.80701754385965);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.52, 1);
    effector:SetKey(_TRACK_O, 1.16, 0);
    effector:SetKey(_TRACK_O, 1.64, 0);
    effector:SetKey(_TRACK_O, 1.9966796875, 1);
    effector:SetKey(_TRACK_O, 2.435625, 0);
    effector:SetKey(_TRACK_O, 2.9522265625, 0);
    effector:SetKey(_TRACK_O, 3.671875, 1);
    effector:SetKey(_TRACK_O, 4.557578125, 0);
    effector:SetKey(_TRACK_O, 5.362421875, 0);
    effector:SetKey(_TRACK_O, 5.882421875, 1);
    effector:SetKey(_TRACK_O, 6.522421875, 0);
    effector:SetKey(_TRACK_O, 7.002421875, 0);
    effector:SetKey(_TRACK_O, 7.3591015625, 1);
    effector:SetKey(_TRACK_O, 7.798046875, 0);
    effector:SetKey(_TRACK_O, 8.3146484375, 0);
    effector:SetKey(_TRACK_O, 9.034296875, 1);
    effector:SetKey(_TRACK_O, 9.92, 0);

    effector:Play();


    -- Layer Layer_6
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_light1_01.jpg');
    element:SetName('Layer_6');
    compositionbackForceField:AddElement(element);
    element:SetHotSpot(58.5, 138);
    element:SetParentElement(compositionbackForceField);
    element:SetXY(680.3603515625, 93.4053955078125);

    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 0.72, 1.03418803418803);
    effector:SetKey(_TRACK_SY, 0.72, 0.99275362318841);
    effector:SetKey(_TRACK_SX, 1.96, 0.92703592703593);
    effector:SetKey(_TRACK_SY, 1.96, 0.9937260806826);
    effector:SetKey(_TRACK_SX, 2.4, 0.96523698523698);
    effector:SetKey(_TRACK_SY, 2.4, 0.98682476943346);
    effector:SetKey(_TRACK_SX, 3, 1.00218398885066);
    effector:SetKey(_TRACK_SY, 3, 0.98787042265303);
    effector:SetKey(_TRACK_SX, 3.72, 0.93358199059348);
    effector:SetKey(_TRACK_SY, 3.72, 0.98912520651651);
    effector:SetKey(_TRACK_SX, 4.4, 0.97500788478095);
    effector:SetKey(_TRACK_SY, 4.4, 0.99031028016535);
    effector:SetKey(_TRACK_SX, 5.24, 0.91040760359625);
    effector:SetKey(_TRACK_SY, 5.24, 0.99177419467275);
    effector:SetKey(_TRACK_SX, 6, 0.9761155492145);
    effector:SetKey(_TRACK_SY, 6, 0.98585231193927);
    effector:SetKey(_TRACK_SX, 6.64, 0.92869361119071);
    effector:SetKey(_TRACK_SY, 6.64, 0.98813880697939);
    effector:SetKey(_TRACK_SX, 7.64, 0.96726545623933);
    effector:SetKey(_TRACK_SY, 7.64, 0.99171145547957);
    effector:SetKey(_TRACK_SX, 8.32, 0.89138997842324);
    effector:SetKey(_TRACK_SY, 8.32, 0.9941408564597);
    effector:SetKey(_TRACK_SX, 9.96, 1);
    effector:SetKey(_TRACK_SY, 9.96, 1);
    effector:SetKey(_TRACK_O, 0, 0.4);
    effector:SetKey(_TRACK_O, 0.64, 0.5);
    effector:SetKey(_TRACK_O, 1.32, 0.3);
    effector:SetKey(_TRACK_O, 1.96, 0.5);
    effector:SetKey(_TRACK_O, 2.36, 0.3);
    effector:SetKey(_TRACK_O, 3.28, 0.55);
    effector:SetKey(_TRACK_O, 4.04, 0.4);
    effector:SetKey(_TRACK_O, 4.76, 0.45);
    effector:SetKey(_TRACK_O, 5.28, 0.35);
    effector:SetKey(_TRACK_O, 5.96, 0.55);
    effector:SetKey(_TRACK_O, 6.36, 0.3);
    effector:SetKey(_TRACK_O, 6.76, 0.45);
    effector:SetKey(_TRACK_O, 7.44, 0.35);
    effector:SetKey(_TRACK_O, 8.16, 0.45);
    effector:SetKey(_TRACK_O, 8.84, 0.3);
    effector:SetKey(_TRACK_O, 9.36, 0.45);
    effector:SetKey(_TRACK_O, 9.96, 0.4);

    effector:Play();

    compositionbackForceField:Play();

    return compositionbackForceField;
end

createCompositionEF_Lightning01_1 = function()

    local compositionEF_Lightning01_1 = CreateCompositionSequence();
    local compositionDuration = 1.12;
    compositionEF_Lightning01_1:SetDuration(compositionDuration);


    -- Layer Layer_1
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Lightning01.jpg');
    element:SetName('Layer_1');
    compositionEF_Lightning01_1:AddElement(element);
    element:SetHotSpot(64.5, 147);
    element:SetParentElement(compositionEF_Lightning01_1);
    element:SetAngle(1.570796325);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 1.12);

    effector:SetKey(_TRACK_X, 0, 61.5450439453125);
    effector:SetKey(_TRACK_Y, 0, 88.0653076171875);
    effector:SetKey(_TRACK_X, 0.08, 61.5450439453125);
    effector:SetKey(_TRACK_Y, 0.08, 84.3153076171875);
    effector:SetKey(_TRACK_X, 0.16, 61.7950439453125);
    effector:SetKey(_TRACK_Y, 0.16, 80.0653076171875);
    effector:SetKey(_TRACK_X, 0.24, 63.0450439453125);
    effector:SetKey(_TRACK_Y, 0.24, 74.8153076171875);
    effector:SetKey(_TRACK_X, 0.32, 63.5450439453125);
    effector:SetKey(_TRACK_Y, 0.32, 70.0653076171875);
    effector:SetKey(_TRACK_X, 0.4, 63.2950439453125);
    effector:SetKey(_TRACK_Y, 0.4, 65.8153076171875);
    effector:SetKey(_TRACK_X, 0.48, 63.2950439453125);
    effector:SetKey(_TRACK_Y, 0.48, 61.3153076171875);
    effector:SetKey(_TRACK_X, 0.56, 62.5450439453125);
    effector:SetKey(_TRACK_Y, 0.56, 56.3153076171875);
    effector:SetKey(_TRACK_X, 0.64, 63.5450439453125);
    effector:SetKey(_TRACK_Y, 0.64, 52.8153076171875);
    effector:SetKey(_TRACK_X, 0.72, 63.7950439453125);
    effector:SetKey(_TRACK_Y, 0.72, 46.5653076171875);
    effector:SetKey(_TRACK_X, 0.8, 62.5450439453125);
    effector:SetKey(_TRACK_Y, 0.8, 40.8153076171875);
    effector:SetKey(_TRACK_X, 0.88, 62.2950439453125);
    effector:SetKey(_TRACK_Y, 0.88, 34.8153076171875);
    effector:SetKey(_TRACK_X, 0.96, 62.7950439453125);
    effector:SetKey(_TRACK_Y, 0.96, 29.5653076171875);
    effector:SetKey(_TRACK_X, 1.04, 62.5450439453125);
    effector:SetKey(_TRACK_Y, 1.04, 20.0653076171875);
    effector:SetKey(_TRACK_X, 1.08, 62.5450439453125);
    effector:SetKey(_TRACK_Y, 1.08, 20.0653076171875);
    effector:SetKey(_TRACK_SX, 0, 0.15971785739228);
    effector:SetKey(_TRACK_SY, 0, 0.22338665195808);
    effector:SetKey(_TRACK_SX, 0.08, 0.15971785739228);
    effector:SetKey(_TRACK_SY, 0.08, 0.22338665195808);
    effector:SetKey(_TRACK_SX, 0.16, -0.13097981702633);
    effector:SetKey(_TRACK_SY, 0.16, 0.21488325059754);
    effector:SetKey(_TRACK_SX, 0.24, 0.24111320622949);
    effector:SetKey(_TRACK_SY, 0.24, 0.18086964515536);
    effector:SetKey(_TRACK_SX, 0.32, -0.1774914449333);
    effector:SetKey(_TRACK_SY, 0.32, -0.18137525280382);
    effector:SetKey(_TRACK_SX, 0.4, 0.14808995041553);
    effector:SetKey(_TRACK_SY, 0.4, 0.16046148189005);
    effector:SetKey(_TRACK_SX, 0.48, -0.21237516586354);
    effector:SetKey(_TRACK_SY, 0.48, 0.15365876080162);
    effector:SetKey(_TRACK_SX, 0.56, 0.19460157832251);
    effector:SetKey(_TRACK_SY, 0.56, 0.15365876080162);
    effector:SetKey(_TRACK_SX, 0.64, -0.25888679377051);
    effector:SetKey(_TRACK_SY, 0.64, -0.13035484464056);
    effector:SetKey(_TRACK_SX, 0.72, 0.23336126824499);
    effector:SetKey(_TRACK_SY, 0.72, 0.11964515535944);
    effector:SetKey(_TRACK_SX, 0.8, -0.23175501082478);
    effector:SetKey(_TRACK_SY, 0.8, 0.10774039345468);
    effector:SetKey(_TRACK_SX, 0.88, 0.11708219847755);
    effector:SetKey(_TRACK_SY, 0.88, 0.07542746828461);
    effector:SetKey(_TRACK_SX, 0.96, -0.23175501082478);
    effector:SetKey(_TRACK_SY, 0.96, 0.06352270637985);
    effector:SetKey(_TRACK_SX, 1.04, 0.24111320622948);
    effector:SetKey(_TRACK_SY, 1.04, 0.04651590365876);
    effector:SetKey(_TRACK_SX, 1.08, 0.24111320622948);
    effector:SetKey(_TRACK_SY, 1.08, 0.04651590365876);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.04, 1);
    effector:SetKey(_TRACK_O, 1.04, 1);
    effector:SetKey(_TRACK_O, 1.08, 0);

    effector:Play();

    compositionEF_Lightning01_1:Play();

    return compositionEF_Lightning01_1;
end

createCompositionfronForceField = function()

    local compositionfronForceField = CreateCompositionSequence();
    local compositionDuration = 10;
    compositionfronForceField:SetDuration(compositionDuration);


    -- Layer Layer_5
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Lightning01.jpg');
    element:SetName('Layer_5');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64.5, 147);
    element:SetParentElement(compositionfronForceField);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 952.376129150391);
    effector:SetKey(_TRACK_Y, 0, 645.362609863281);
    effector:SetKey(_TRACK_X, 0.0328515625, 950.626129150391);
    effector:SetKey(_TRACK_Y, 0.0328515625, 645.362609863281);
    effector:SetKey(_TRACK_X, 0.0986328125, 946.126129150391);
    effector:SetKey(_TRACK_Y, 0.0986328125, 645.612609863281);
    effector:SetKey(_TRACK_X, 0.164375, 940.626129150391);
    effector:SetKey(_TRACK_Y, 0.164375, 642.362609863281);
    effector:SetKey(_TRACK_X, 0.23015625, 934.876129150391);
    effector:SetKey(_TRACK_Y, 0.23015625, 644.112609863281);
    effector:SetKey(_TRACK_X, 0.2959375, 926.626129150391);
    effector:SetKey(_TRACK_Y, 0.2959375, 644.112609863281);
    effector:SetKey(_TRACK_X, 0.3616796875, 921.376129150391);
    effector:SetKey(_TRACK_Y, 0.3616796875, 640.612609863281);
    effector:SetKey(_TRACK_X, 0.4274609375, 916.626129150391);
    effector:SetKey(_TRACK_Y, 0.4274609375, 644.362609863281);
    effector:SetKey(_TRACK_X, 0.4931640625, 911.876129150391);
    effector:SetKey(_TRACK_Y, 0.4931640625, 644.112609863281);
    effector:SetKey(_TRACK_X, 0.558984375, 904.126129150391);
    effector:SetKey(_TRACK_Y, 0.558984375, 642.862609863281);
    effector:SetKey(_TRACK_X, 0.5918359375, 901.376129150391);
    effector:SetKey(_TRACK_Y, 0.5918359375, 643.862609863281);
    effector:SetKey(_TRACK_X, 0.8, 952.376129150391);
    effector:SetKey(_TRACK_Y, 0.8, 645.362609863281);
    effector:SetKey(_TRACK_X, 0.84, 950.626129150391);
    effector:SetKey(_TRACK_Y, 0.84, 645.362609863281);
    effector:SetKey(_TRACK_X, 0.92, 946.126129150391);
    effector:SetKey(_TRACK_Y, 0.92, 645.612609863281);
    effector:SetKey(_TRACK_X, 1, 940.626129150391);
    effector:SetKey(_TRACK_Y, 1, 642.362609863281);
    effector:SetKey(_TRACK_X, 1.08, 934.876129150391);
    effector:SetKey(_TRACK_Y, 1.08, 644.112609863281);
    effector:SetKey(_TRACK_X, 1.16, 926.626129150391);
    effector:SetKey(_TRACK_Y, 1.16, 644.112609863281);
    effector:SetKey(_TRACK_X, 1.24, 921.376129150391);
    effector:SetKey(_TRACK_Y, 1.24, 640.612609863281);
    effector:SetKey(_TRACK_X, 1.32, 916.626129150391);
    effector:SetKey(_TRACK_Y, 1.32, 644.362609863281);
    effector:SetKey(_TRACK_X, 1.4, 911.876129150391);
    effector:SetKey(_TRACK_Y, 1.4, 644.112609863281);
    effector:SetKey(_TRACK_X, 1.48, 904.126129150391);
    effector:SetKey(_TRACK_Y, 1.48, 642.862609863281);
    effector:SetKey(_TRACK_X, 1.52, 901.376129150391);
    effector:SetKey(_TRACK_Y, 1.52, 643.862609863281);
    effector:SetKey(_TRACK_X, 3.36, 952.376129150391);
    effector:SetKey(_TRACK_Y, 3.36, 645.362609863281);
    effector:SetKey(_TRACK_X, 3.4, 950.626129150391);
    effector:SetKey(_TRACK_Y, 3.4, 645.362609863281);
    effector:SetKey(_TRACK_X, 3.48, 946.126129150391);
    effector:SetKey(_TRACK_Y, 3.48, 645.612609863281);
    effector:SetKey(_TRACK_X, 3.56, 940.626129150391);
    effector:SetKey(_TRACK_Y, 3.56, 642.362609863281);
    effector:SetKey(_TRACK_X, 3.64, 934.876129150391);
    effector:SetKey(_TRACK_Y, 3.64, 644.112609863281);
    effector:SetKey(_TRACK_X, 3.72, 926.626129150391);
    effector:SetKey(_TRACK_Y, 3.72, 644.112609863281);
    effector:SetKey(_TRACK_X, 3.8, 921.376129150391);
    effector:SetKey(_TRACK_Y, 3.8, 640.612609863281);
    effector:SetKey(_TRACK_X, 3.88, 916.626129150391);
    effector:SetKey(_TRACK_Y, 3.88, 644.362609863281);
    effector:SetKey(_TRACK_X, 3.96, 911.876129150391);
    effector:SetKey(_TRACK_Y, 3.96, 644.112609863281);
    effector:SetKey(_TRACK_X, 4.04, 904.126129150391);
    effector:SetKey(_TRACK_Y, 4.04, 642.862609863281);
    effector:SetKey(_TRACK_X, 4.08, 901.376129150391);
    effector:SetKey(_TRACK_Y, 4.08, 643.862609863281);
    effector:SetKey(_TRACK_X, 4.84, 952.376129150391);
    effector:SetKey(_TRACK_Y, 4.84, 645.362609863281);
    effector:SetKey(_TRACK_X, 4.88, 950.626129150391);
    effector:SetKey(_TRACK_Y, 4.88, 645.362609863281);
    effector:SetKey(_TRACK_X, 4.96, 946.126129150391);
    effector:SetKey(_TRACK_Y, 4.96, 645.612609863281);
    effector:SetKey(_TRACK_X, 5.08, 904.126129150391);
    effector:SetKey(_TRACK_Y, 5.08, 642.862609863281);
    effector:SetKey(_TRACK_X, 5.12, 901.376129150391);
    effector:SetKey(_TRACK_Y, 5.12, 643.862609863281);
    effector:SetKey(_TRACK_SX, 0, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 0, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 0.0328515625, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 0.0328515625, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 0.0986328125, -0.24778266638732);
    effector:SetKey(_TRACK_SY, 0.0986328125, -0.25917754489183);
    effector:SetKey(_TRACK_SX, 0.1315234375, 0.00147430299665);
    effector:SetKey(_TRACK_SY, 0.1315234375, -0.07569614192773);
    effector:SetKey(_TRACK_SX, 0.164375, 0.34136462043439);
    effector:SetKey(_TRACK_SY, 0.164375, -0.26768094625237);
    effector:SetKey(_TRACK_SX, 0.23015625, 0.42562966200653);
    effector:SetKey(_TRACK_SY, 0.23015625, 0.2713118402755);
    effector:SetKey(_TRACK_SX, 0.2959375, -0.33217936357145);
    effector:SetKey(_TRACK_SY, 0.2959375, -0.30003571760742);
    effector:SetKey(_TRACK_SX, 0.3287890625, -0.26482980318023);
    effector:SetKey(_TRACK_SY, 0.3287890625, -0.2150140200101);
    effector:SetKey(_TRACK_SX, 0.3616796875, -0.64579329220517);
    effector:SetKey(_TRACK_SY, 0.3616796875, 0.26704153747174);
    effector:SetKey(_TRACK_SX, 0.39453125, -0.4314102545955);
    effector:SetKey(_TRACK_SY, 0.39453125, -0.24351292089798);
    effector:SetKey(_TRACK_SX, 0.4274609375, -0.33700566491055);
    effector:SetKey(_TRACK_SY, 0.4274609375, -0.29509217252242);
    effector:SetKey(_TRACK_SX, 0.4603125, -0.17650136077345);
    effector:SetKey(_TRACK_SY, 0.4603125, -0.20910563567447);
    effector:SetKey(_TRACK_SX, 0.4931640625, -0.40062917231189);
    effector:SetKey(_TRACK_SY, 0.4931640625, 0.25161914314072);
    effector:SetKey(_TRACK_SX, 0.52609375, -0.25665266527854);
    effector:SetKey(_TRACK_SY, 0.52609375, 0.21360040696171);
    effector:SetKey(_TRACK_SX, 0.558984375, -0.29738486999392);
    effector:SetKey(_TRACK_SY, 0.558984375, -0.24033468648402);
    effector:SetKey(_TRACK_SX, 0.5918359375, 0.27872166138797);
    effector:SetKey(_TRACK_SY, 0.5918359375, 0.20228836342715);
    effector:SetKey(_TRACK_SX, 0.8, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 0.8, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 0.84, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 0.84, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 0.92, -0.24778266638732);
    effector:SetKey(_TRACK_SY, 0.92, -0.25917754489183);
    effector:SetKey(_TRACK_SX, 0.96, 0.00147430299665);
    effector:SetKey(_TRACK_SY, 0.96, -0.07569614192773);
    effector:SetKey(_TRACK_SX, 1, 0.34136462043439);
    effector:SetKey(_TRACK_SY, 1, -0.26768094625237);
    effector:SetKey(_TRACK_SX, 1.08, 0.42562966200653);
    effector:SetKey(_TRACK_SY, 1.08, 0.2713118402755);
    effector:SetKey(_TRACK_SX, 1.16, -0.33217936357145);
    effector:SetKey(_TRACK_SY, 1.16, -0.30003571760742);
    effector:SetKey(_TRACK_SX, 1.2, -0.26482980318023);
    effector:SetKey(_TRACK_SY, 1.2, -0.2150140200101);
    effector:SetKey(_TRACK_SX, 1.24, -0.64579329220517);
    effector:SetKey(_TRACK_SY, 1.24, 0.26704153747174);
    effector:SetKey(_TRACK_SX, 1.28, -0.4314102545955);
    effector:SetKey(_TRACK_SY, 1.28, -0.24351292089798);
    effector:SetKey(_TRACK_SX, 1.32, -0.33700566491055);
    effector:SetKey(_TRACK_SY, 1.32, -0.29509217252242);
    effector:SetKey(_TRACK_SX, 1.36, -0.17650136077345);
    effector:SetKey(_TRACK_SY, 1.36, -0.20910563567447);
    effector:SetKey(_TRACK_SX, 1.4, -0.40062917231189);
    effector:SetKey(_TRACK_SY, 1.4, 0.25161914314072);
    effector:SetKey(_TRACK_SX, 1.44, -0.25665266527854);
    effector:SetKey(_TRACK_SY, 1.44, 0.21360040696171);
    effector:SetKey(_TRACK_SX, 1.48, -0.29738486999392);
    effector:SetKey(_TRACK_SY, 1.48, -0.24033468648402);
    effector:SetKey(_TRACK_SX, 1.52, 0.27872166138797);
    effector:SetKey(_TRACK_SY, 1.52, 0.20228836342715);
    effector:SetKey(_TRACK_SX, 3.36, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 3.36, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 3.4, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 3.4, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 3.48, -0.24778266638732);
    effector:SetKey(_TRACK_SY, 3.48, -0.25917754489183);
    effector:SetKey(_TRACK_SX, 3.52, 0.00147430299665);
    effector:SetKey(_TRACK_SY, 3.52, -0.07569614192773);
    effector:SetKey(_TRACK_SX, 3.56, 0.34136462043439);
    effector:SetKey(_TRACK_SY, 3.56, -0.26768094625237);
    effector:SetKey(_TRACK_SX, 3.64, 0.42562966200653);
    effector:SetKey(_TRACK_SY, 3.64, 0.2713118402755);
    effector:SetKey(_TRACK_SX, 3.72, -0.33217936357145);
    effector:SetKey(_TRACK_SY, 3.72, -0.30003571760742);
    effector:SetKey(_TRACK_SX, 3.76, -0.26482980318023);
    effector:SetKey(_TRACK_SY, 3.76, -0.2150140200101);
    effector:SetKey(_TRACK_SX, 3.8, -0.64579329220517);
    effector:SetKey(_TRACK_SY, 3.8, 0.26704153747174);
    effector:SetKey(_TRACK_SX, 3.84, -0.4314102545955);
    effector:SetKey(_TRACK_SY, 3.84, -0.24351292089798);
    effector:SetKey(_TRACK_SX, 3.88, -0.33700566491055);
    effector:SetKey(_TRACK_SY, 3.88, -0.29509217252242);
    effector:SetKey(_TRACK_SX, 3.92, -0.17650136077345);
    effector:SetKey(_TRACK_SY, 3.92, -0.20910563567447);
    effector:SetKey(_TRACK_SX, 3.96, -0.40062917231189);
    effector:SetKey(_TRACK_SY, 3.96, 0.25161914314072);
    effector:SetKey(_TRACK_SX, 4, -0.25665266527854);
    effector:SetKey(_TRACK_SY, 4, 0.21360040696171);
    effector:SetKey(_TRACK_SX, 4.04, -0.29738486999392);
    effector:SetKey(_TRACK_SY, 4.04, -0.24033468648402);
    effector:SetKey(_TRACK_SX, 4.08, 0.27872166138797);
    effector:SetKey(_TRACK_SY, 4.08, 0.20228836342715);
    effector:SetKey(_TRACK_SX, 4.84, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 4.84, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 4.88, 0.28322508555067);
    effector:SetKey(_TRACK_SY, 4.88, 0.22211497211497);
    effector:SetKey(_TRACK_SX, 4.96, -0.24778266638732);
    effector:SetKey(_TRACK_SY, 4.96, -0.25917754489183);
    effector:SetKey(_TRACK_SX, 5, 0.00147430299665);
    effector:SetKey(_TRACK_SY, 5, -0.07569614192773);
    effector:SetKey(_TRACK_SX, 5.08, -0.29738486999392);
    effector:SetKey(_TRACK_SY, 5.08, -0.24033468648402);
    effector:SetKey(_TRACK_SX, 5.12, 0.27872166138797);
    effector:SetKey(_TRACK_SY, 5.12, 0.20228836342715);
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 0.0986328125, -0.05863448298175);
    effector:SetKey(_TRACK_A, 0.164375, -0.17042723622518);
    effector:SetKey(_TRACK_A, 0.23015625, -0.082970435828);
    effector:SetKey(_TRACK_A, 0.558984375, 0.33024408795418);
    effector:SetKey(_TRACK_A, 0.8, 0);
    effector:SetKey(_TRACK_A, 0.92, -0.05863448298175);
    effector:SetKey(_TRACK_A, 1, -0.17042723622518);
    effector:SetKey(_TRACK_A, 1.08, -0.082970435828);
    effector:SetKey(_TRACK_A, 1.48, 0.33024408795418);
    effector:SetKey(_TRACK_A, 3.36, 0);
    effector:SetKey(_TRACK_A, 3.48, -0.05863448298175);
    effector:SetKey(_TRACK_A, 3.56, -0.17042723622518);
    effector:SetKey(_TRACK_A, 3.64, -0.082970435828);
    effector:SetKey(_TRACK_A, 4.04, 0.33024408795418);
    effector:SetKey(_TRACK_A, 4.84, 0);
    effector:SetKey(_TRACK_A, 4.96, -0.05863448298175);
    effector:SetKey(_TRACK_A, 5.08, 0.33024408795418);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.0328515625, 1);
    effector:SetKey(_TRACK_O, 0.558984375, 1);
    effector:SetKey(_TRACK_O, 0.5918359375, 0);
    effector:SetKey(_TRACK_O, 0.8, 0);
    effector:SetKey(_TRACK_O, 0.84, 1);
    effector:SetKey(_TRACK_O, 1.48, 1);
    effector:SetKey(_TRACK_O, 1.52, 0);
    effector:SetKey(_TRACK_O, 3.36, 0);
    effector:SetKey(_TRACK_O, 3.4, 1);
    effector:SetKey(_TRACK_O, 4.04, 1);
    effector:SetKey(_TRACK_O, 4.08, 0);
    effector:SetKey(_TRACK_O, 4.84, 0);
    effector:SetKey(_TRACK_O, 4.88, 1);
    effector:SetKey(_TRACK_O, 5.08, 1);
    effector:SetKey(_TRACK_O, 5.12, 0);

    effector:Play();


    -- Layer Layer_6
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_6');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(537.369369506836, 226.018020629883);

    element:SetScaleX(0.83783783783784);
    element:SetScaleY(0.94594594594595);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(7.88, 9);


    effector:Play();


    -- Layer Layer_7
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_7');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(537.369369506836, 226.018020629883);

    element:SetScaleX(0.83783783783784);
    element:SetScaleY(0.94594594594595);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(3.4, 4.52);


    effector:Play();


    -- Layer Layer_8
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_8');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(811.81982421875, 224.864868164063);

    element:SetScaleX(0.83783783783784);
    element:SetScaleY(0.94594594594595);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(5.2, 6.32);


    effector:Play();


    -- Layer Layer_9
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_9');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(811.81982421875, 224.864868164063);

    element:SetScaleX(0.83783783783784);
    element:SetScaleY(0.94594594594595);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(0.48, 1.6);


    effector:Play();


    -- Layer Layer_10
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_10');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(694.198196411133, 224.864868164063);

    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(5.64, 6.76);


    effector:Play();


    -- Layer Layer_11
    local element = createCompositionEF_Lightning01_1();
    element:SetName('Layer_11');
    compositionfronForceField:AddElement(element);
    element:SetHotSpot(64, 64);
    element:SetParentElement(compositionfronForceField);
    element:SetXY(694.198196411133, 224.864868164063);

    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    element:SetOpacity(1);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 1.12);


    effector:Play();

    compositionfronForceField:Play();

    return compositionfronForceField;
end

createCompositionfrontEnv = function()

    local compositionfrontEnv = CreateCompositionSequence();
    local compositionDuration = 10;
    compositionfrontEnv:SetDuration(compositionDuration);


    -- Layer Layer_4
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_light2_01.jpg');
    element:SetName('Layer_4');
    compositionfrontEnv:AddElement(element);
    element:SetHotSpot(64, 61.5);
    element:SetParentElement(compositionfrontEnv);
    element:SetXY(221.405410766602, 146.450469970703);

    element:SetScaleX(5.30630630630631);
    element:SetScaleY(7.95012085255988);
    element:SetAngle(0);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_O, 0, 0.1);
    effector:SetKey(_TRACK_O, 0.52, 0.2);
    effector:SetKey(_TRACK_O, 1.12, 0.05);
    effector:SetKey(_TRACK_O, 1.88, 0.4);
    effector:SetKey(_TRACK_O, 2.64, 0.2);
    effector:SetKey(_TRACK_O, 3.44, 0.3);
    effector:SetKey(_TRACK_O, 4.24, 0.05);
    effector:SetKey(_TRACK_O, 5.2, 0.45);
    effector:SetKey(_TRACK_O, 5.76, 0.2);
    effector:SetKey(_TRACK_O, 6.32, 0.25);
    effector:SetKey(_TRACK_O, 7.08, 0.05);
    effector:SetKey(_TRACK_O, 7.8, 0.25);
    effector:SetKey(_TRACK_O, 8.52, 0.05);
    effector:SetKey(_TRACK_O, 9.96, 0.1);

    effector:Play();


    -- Layer Layer_3
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Dust_02.jpg');
    element:SetName('Layer_3');
    compositionfrontEnv:AddElement(element);
    element:SetHotSpot(130.5, 131);
    element:SetParentElement(compositionfrontEnv);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 144.144149780273);
    effector:SetKey(_TRACK_Y, 0, 616.936935424805);
    effector:SetKey(_TRACK_X, 1.2410546875, 152.216217041016);
    effector:SetKey(_TRACK_Y, 1.2410546875, 590.414413452148);
    effector:SetKey(_TRACK_X, 2.482109375, 153.369369506836);
    effector:SetKey(_TRACK_Y, 2.482109375, 562.738739013672);
    effector:SetKey(_TRACK_X, 4.0334375, 141.837844848633);
    effector:SetKey(_TRACK_Y, 4.0334375, 533.909912109375);
    effector:SetKey(_TRACK_X, 5.2744921875, 139.531539916992);
    effector:SetKey(_TRACK_Y, 5.2744921875, 505.081085205078);
    effector:SetKey(_TRACK_X, 6.82578125, 146.450454711914);
    effector:SetKey(_TRACK_Y, 6.82578125, 478.558563232422);
    effector:SetKey(_TRACK_X, 8.377109375, 152.216217041016);
    effector:SetKey(_TRACK_Y, 8.377109375, 442.810821533203);
    effector:SetKey(_TRACK_X, 9.9284375, 139.531539916992);
    effector:SetKey(_TRACK_Y, 9.9284375, 409.369384765625);
    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 9.96, 1.5);
    effector:SetKey(_TRACK_SY, 9.96, 1.5);
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 9.96, -0.7853981625);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.48, 1);
    effector:SetKey(_TRACK_O, 1.12, 0.4);
    effector:SetKey(_TRACK_O, 1.6, 0.8);
    effector:SetKey(_TRACK_O, 1.92, 0);
    effector:SetKey(_TRACK_O, 2.44, 1);
    effector:SetKey(_TRACK_O, 2.96, 0.4);
    effector:SetKey(_TRACK_O, 3.52, 1);
    effector:SetKey(_TRACK_O, 4.16, 0);
    effector:SetKey(_TRACK_O, 4.8, 1);
    effector:SetKey(_TRACK_O, 5.28, 0.2);
    effector:SetKey(_TRACK_O, 5.84, 0.8);
    effector:SetKey(_TRACK_O, 6.4, 0.1);
    effector:SetKey(_TRACK_O, 7.16, 1);
    effector:SetKey(_TRACK_O, 7.72, 0.6);
    effector:SetKey(_TRACK_O, 8.44, 0.2);
    effector:SetKey(_TRACK_O, 8.88, 0.4);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();


    -- Layer Layer_2
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Dust_02.jpg');
    element:SetName('Layer_2');
    compositionfrontEnv:AddElement(element);
    element:SetHotSpot(130.5, 131);
    element:SetParentElement(compositionfrontEnv);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 251.387390136719);
    effector:SetKey(_TRACK_Y, 0, 428.97297668457);
    effector:SetKey(_TRACK_X, 1.2410546875, 259.459457397461);
    effector:SetKey(_TRACK_Y, 1.2410546875, 402.450454711914);
    effector:SetKey(_TRACK_X, 2.482109375, 260.612609863281);
    effector:SetKey(_TRACK_Y, 2.482109375, 374.774780273438);
    effector:SetKey(_TRACK_X, 4.0334375, 249.081085205078);
    effector:SetKey(_TRACK_Y, 4.0334375, 345.945953369141);
    effector:SetKey(_TRACK_X, 5.2744921875, 246.774780273438);
    effector:SetKey(_TRACK_Y, 5.2744921875, 317.117126464844);
    effector:SetKey(_TRACK_X, 6.82578125, 253.693695068359);
    effector:SetKey(_TRACK_Y, 6.82578125, 290.594604492188);
    effector:SetKey(_TRACK_X, 8.377109375, 259.459457397461);
    effector:SetKey(_TRACK_Y, 8.377109375, 254.846862792969);
    effector:SetKey(_TRACK_X, 9.9284375, 246.774780273438);
    effector:SetKey(_TRACK_Y, 9.9284375, 221.405426025391);
    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 9.96, 1.5);
    effector:SetKey(_TRACK_SY, 9.96, 1.5);
    effector:SetKey(_TRACK_A, 0, 0.7853981625);
    effector:SetKey(_TRACK_A, 9.96, 0.7853981625);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.48, 1);
    effector:SetKey(_TRACK_O, 1.12, 0.4);
    effector:SetKey(_TRACK_O, 1.6, 0.8);
    effector:SetKey(_TRACK_O, 1.92, 0);
    effector:SetKey(_TRACK_O, 2.44, 1);
    effector:SetKey(_TRACK_O, 2.96, 0.4);
    effector:SetKey(_TRACK_O, 3.52, 1);
    effector:SetKey(_TRACK_O, 4.16, 0);
    effector:SetKey(_TRACK_O, 4.8, 1);
    effector:SetKey(_TRACK_O, 5.28, 0.2);
    effector:SetKey(_TRACK_O, 5.84, 0.8);
    effector:SetKey(_TRACK_O, 6.4, 0.1);
    effector:SetKey(_TRACK_O, 7.16, 1);
    effector:SetKey(_TRACK_O, 7.72, 0.6);
    effector:SetKey(_TRACK_O, 8.44, 0.2);
    effector:SetKey(_TRACK_O, 8.88, 0.4);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();


    -- Layer Layer_1
    local element = auxCreateCompositionElement('data/Texture/Scenes/17_CandleCave/Animations/Env/EF_Dust_02.jpg');
    element:SetName('Layer_1');
    compositionfrontEnv:AddElement(element);
    element:SetHotSpot(130.5, 131);
    element:SetParentElement(compositionfrontEnv);

    effector = element:GetEffector();
    effector:SetLifeTime(0, 10);

    effector:SetKey(_TRACK_X, 0, 612.324325561523);
    effector:SetKey(_TRACK_Y, 0, 614.630630493164);
    effector:SetKey(_TRACK_X, 1.2410546875, 620.396392822266);
    effector:SetKey(_TRACK_Y, 1.2410546875, 588.108108520508);
    effector:SetKey(_TRACK_X, 2.482109375, 621.549545288086);
    effector:SetKey(_TRACK_Y, 2.482109375, 560.432434082031);
    effector:SetKey(_TRACK_X, 4.0334375, 610.018020629883);
    effector:SetKey(_TRACK_Y, 4.0334375, 531.603607177734);
    effector:SetKey(_TRACK_X, 5.2744921875, 607.711715698242);
    effector:SetKey(_TRACK_Y, 5.2744921875, 502.774780273438);
    effector:SetKey(_TRACK_X, 6.82578125, 614.630630493164);
    effector:SetKey(_TRACK_Y, 6.82578125, 476.252258300781);
    effector:SetKey(_TRACK_X, 8.377109375, 620.396392822266);
    effector:SetKey(_TRACK_Y, 8.377109375, 440.504516601563);
    effector:SetKey(_TRACK_X, 9.9284375, 607.711715698242);
    effector:SetKey(_TRACK_Y, 9.9284375, 407.063079833984);
    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 9.96, 1.5);
    effector:SetKey(_TRACK_SY, 9.96, 1.5);
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 9.96, -0.7853981625);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.84, 0.4);
    effector:SetKey(_TRACK_O, 1.36, 1);
    effector:SetKey(_TRACK_O, 2, 0.4);
    effector:SetKey(_TRACK_O, 2.48, 0.8);
    effector:SetKey(_TRACK_O, 2.8, 0);
    effector:SetKey(_TRACK_O, 3.32, 1);
    effector:SetKey(_TRACK_O, 3.84, 0.4);
    effector:SetKey(_TRACK_O, 4.4, 1);
    effector:SetKey(_TRACK_O, 5.04, 0);
    effector:SetKey(_TRACK_O, 5.68, 1);
    effector:SetKey(_TRACK_O, 6.16, 0.2);
    effector:SetKey(_TRACK_O, 6.72, 0.8);
    effector:SetKey(_TRACK_O, 7.28, 0.1);
    effector:SetKey(_TRACK_O, 8.04, 1);
    effector:SetKey(_TRACK_O, 8.6, 0.6);
    effector:SetKey(_TRACK_O, 9.32, 0.2);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();

    compositionfrontEnv:Play();

    return compositionfrontEnv;
end
