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

--// 1.	rename:					" -> '
--// 2. comment root composition with texture "createCompositionBackground01 = function()"
--// 3. add auxiliaru routines for managing animations: 
--		auxPlayDinoFieldEnvAnimation(), 
--		auxGetDinoFieldEnvAnimation(), 
--		auxCreateDinoFieldEnvAnimations()
--// 4. replace CreateCompositionElement() with auxCreateCompositionElement() for some corrections ...

------------------------------------------------------------------------------
--
function auxPlayDinoFieldEnvAnimation(compositionName)
    local composition = auxGetDinoFieldEnvAnimation(compositionName);
    composition:SetVisible(true);
    composition:Play();
end

------------------------------------------------------------------------------
--
function auxHideDinoFieldEnvAnimation(compositionName)
    local composition = auxGetDinoFieldEnvAnimation(compositionName);
    composition:Stop();
    composition:SetVisible(false);
end

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

    return dinoFieldEnvCompositions[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/19_DinoField/Animations/Env/') + 1);


    --// set up dragonfly animation
	if (texName == 'DF1_[0000-0004].png') then
		local anim = element:GetTexture();
		anim:Stop();
		anim:SetTextureRect(0,0, 128,96);
		anim:SetFrames(5);
		anim:SetFrame(0);
		anim:SetSpeed(30.0);
		anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
		anim:Play();
    end
    --// set up butterfly animation
	if (texName == 'BF_[0-5].png') then
		local anim = element:GetTexture();
		anim:Stop();
		anim:SetTextureRect(0,0, 80,48);
		anim:SetFrames(6);
		anim:SetFrame(0);
		anim:SetSpeed(30.0);
		anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
		anim:Play();
    end
    --// set additive alpha blending mode for light & flare objects without alpha chanel (*.jpg)
    if (texName == 'EF_water01.jpg' or 
		texName == 'EF_Light01.jpg') then

        element:GetTexture():SetBlendMode(0);
    end
	return element;
end

------------------------------------------------------------------------------
--
function auxCreateDinoFieldEnvAnimations(parent)
    assert(parent ~= nil);
    dinoFieldEnvCompositions = {};
    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);
        dinoFieldEnvCompositions[element:GetName()] = element;
    end
    
    CreateAndRegisterComposition(parent, createCompositionEnvFront, 'EnvFront', 0,0,108.0, 512,384, 10, true);
    CreateAndRegisterComposition(parent, createCompositionEnvBack,  'EnvBack', 	0,0,100.0, 512,384, 10, true);
end

------------------------------------------------------------------------------
--
--createCompositionBackground01 = function()
--
--    local compositionBackground01 = CreateCompositionSequence();
--    local compositionDuration = 10;
--    compositionBackground01:SetDuration(compositionDuration);
--
--
--    -- Layer Layer_1
--    local element = createCompositionEnvFront();
--    element:SetName('Layer_1');
--    compositionBackground01:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBackground01);
--    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 = createCompositionEnvBack();
--    element:SetName('Layer_2');
--    compositionBackground01:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBackground01);
--    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 = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Background01.jpg');
--    element:SetName('Layer_3');
--    compositionBackground01:AddElement(element);
--    element:SetHotSpot(512, 384);
--    element:SetParentElement(compositionBackground01);
--    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();
--
--    compositionBackground01:Play();
--
--    return compositionBackground01;
--end

createCompositionEnvBack = function()

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


    -- Layer Layer_1
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Birds3_01.png');
    element:SetName('Layer_1');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(15, 15);
    element:SetParentElement(compositionEnvBack);
    element:SetScaleX(1);
    element:SetScaleY(1);

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

    effector:SetKey(_TRACK_X, 0, 786.450454711914);
    effector:SetKey(_TRACK_Y, 0, 62.2702789306641);
    effector:SetKey(_TRACK_X, 0.44, 758.450454711914);
    effector:SetKey(_TRACK_Y, 0.44, 83.7702789306641);
    effector:SetKey(_TRACK_X, 0.88, 741.950454711914);
    effector:SetKey(_TRACK_Y, 0.88, 102.270278930664);
    effector:SetKey(_TRACK_X, 1.28, 724.950454711914);
    effector:SetKey(_TRACK_Y, 1.28, 119.270278930664);
    effector:SetKey(_TRACK_X, 1.64, 696.450454711914);
    effector:SetKey(_TRACK_Y, 1.64, 134.270278930664);
    effector:SetKey(_TRACK_X, 2.12, 666.450454711914);
    effector:SetKey(_TRACK_Y, 2.12, 140.270278930664);
    effector:SetKey(_TRACK_X, 2.64, 626.450454711914);
    effector:SetKey(_TRACK_Y, 2.64, 134.770278930664);
    effector:SetKey(_TRACK_X, 3.28, 583.950454711914);
    effector:SetKey(_TRACK_Y, 3.28, 136.770278930664);
    effector:SetKey(_TRACK_X, 3.88, 552.450454711914);
    effector:SetKey(_TRACK_Y, 3.88, 150.770278930664);
    effector:SetKey(_TRACK_X, 4.52, 517.950454711914);
    effector:SetKey(_TRACK_Y, 4.52, 178.770278930664);
    effector:SetKey(_TRACK_X, 5.12, 483.450454711914);
    effector:SetKey(_TRACK_Y, 5.12, 194.020278930664);
    effector:SetKey(_TRACK_X, 5.72, 444.950454711914);
    effector:SetKey(_TRACK_Y, 5.72, 197.520278930664);
    effector:SetKey(_TRACK_X, 6.44, 408.950454711914);
    effector:SetKey(_TRACK_Y, 6.44, 190.020278930664);
    effector:SetKey(_TRACK_X, 7.16, 369.450454711914);
    effector:SetKey(_TRACK_Y, 7.16, 174.020278930664);
    effector:SetKey(_TRACK_X, 7.92, 327.950454711914);
    effector:SetKey(_TRACK_Y, 7.92, 163.020278930664);
    effector:SetKey(_TRACK_X, 8.72, 281.950454711914);
    effector:SetKey(_TRACK_Y, 8.72, 158.020278930664);
    effector:SetKey(_TRACK_A, 0, -0.72701678434847);
    effector:SetKey(_TRACK_A, 2.12, -0.45182491082469);
    effector:SetKey(_TRACK_A, 3.92, -0.9248648729318);
    effector:SetKey(_TRACK_A, 7.32, -0.48978415872508);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 8.2, 1);
    effector:SetKey(_TRACK_O, 8.32, 0);

    effector:Play();


    -- Layer Layer_2
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Birds2_01.png');
    element:SetName('Layer_2');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(17, 10);
    element:SetParentElement(compositionEnvBack);

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

    effector:SetKey(_TRACK_X, 0, 705.283782958984);
    effector:SetKey(_TRACK_Y, 0, -11.9864959716797);
    effector:SetKey(_TRACK_X, 0.64, 669.783782958984);
    effector:SetKey(_TRACK_Y, 0.64, 24.0135040283203);
    effector:SetKey(_TRACK_X, 1.32, 631.783782958984);
    effector:SetKey(_TRACK_Y, 1.32, 46.0135040283203);
    effector:SetKey(_TRACK_X, 2.08, 595.783782958984);
    effector:SetKey(_TRACK_Y, 2.08, 53.0135040283203);
    effector:SetKey(_TRACK_X, 2.4, 575.666173915829);
    effector:SetKey(_TRACK_Y, 2.4, 51.3076315495786);
    effector:SetKey(_TRACK_X, 2.76, 557.283782958984);
    effector:SetKey(_TRACK_Y, 2.76, 43.0135040283203);
    effector:SetKey(_TRACK_X, 3.2, 535.283782958984);
    effector:SetKey(_TRACK_Y, 3.2, 38.5135040283203);
    effector:SetKey(_TRACK_X, 3.68, 511.783782958984);
    effector:SetKey(_TRACK_Y, 3.68, 48.0135040283203);
    effector:SetKey(_TRACK_X, 4.16, 496.283782958984);
    effector:SetKey(_TRACK_Y, 4.16, 67.0135040283203);
    effector:SetKey(_TRACK_X, 4.56, 481.783782958984);
    effector:SetKey(_TRACK_Y, 4.56, 94.0135040283203);
    effector:SetKey(_TRACK_X, 5.08, 464.783782958984);
    effector:SetKey(_TRACK_Y, 5.08, 135.01350402832);
    effector:SetKey(_TRACK_X, 5.72, 435.283782958984);
    effector:SetKey(_TRACK_Y, 5.72, 186.51350402832);
    effector:SetKey(_TRACK_X, 6.24, 397.783782958984);
    effector:SetKey(_TRACK_Y, 6.24, 232.51350402832);
    effector:SetKey(_TRACK_X, 6.84, 343.283782958984);
    effector:SetKey(_TRACK_Y, 6.84, 271.01350402832);
    effector:SetKey(_TRACK_X, 7.24, 312.362627465674);
    effector:SetKey(_TRACK_Y, 7.24, 285.697741282488);
    effector:SetKey(_TRACK_X, 7.6, 278.283782958984);
    effector:SetKey(_TRACK_Y, 7.6, 287.51350402832);
    effector:SetKey(_TRACK_X, 8, 238.283782958984);
    effector:SetKey(_TRACK_Y, 8, 265.01350402832);
    effector:SetKey(_TRACK_SX, 0, -0.6);
    effector:SetKey(_TRACK_SY, 0, 0.6);
    effector:SetKey(_TRACK_SX, 8, -1);
    effector:SetKey(_TRACK_SY, 8, 1);
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.04, -0.22111366331103);
    effector:SetKey(_TRACK_A, 2.88, 0.34436673917881);
    effector:SetKey(_TRACK_A, 5.12, -0.62340162685913);
    effector:SetKey(_TRACK_A, 6.96, 0.12932103663484);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 7.76, 1);
    effector:SetKey(_TRACK_O, 7.88, 0);

    effector:Play();


    -- Layer Layer_3
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Birds1_01.png');
    element:SetName('Layer_3');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(37, 17);
    element:SetParentElement(compositionEnvBack);
    element:SetAngle(0);

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

    effector:SetKey(_TRACK_X, 0, 296.900894165039);
    effector:SetKey(_TRACK_Y, 0, -25.1756744384766);
    effector:SetKey(_TRACK_X, 0.76, 344.364852905273);
    effector:SetKey(_TRACK_Y, 0.76, 14.8693695068359);
    effector:SetKey(_TRACK_X, 2.64, 420.063049316406);
    effector:SetKey(_TRACK_Y, 2.64, 45.8603668212891);
    effector:SetKey(_TRACK_X, 3.6, 456.063049316406);
    effector:SetKey(_TRACK_Y, 3.6, 51.3603668212891);
    effector:SetKey(_TRACK_X, 5.2, 506.063049316406);
    effector:SetKey(_TRACK_Y, 5.2, 49.8603668212891);
    effector:SetKey(_TRACK_X, 6.28, 522.563049316406);
    effector:SetKey(_TRACK_Y, 6.28, 46.3603668212891);
    effector:SetKey(_TRACK_X, 7.64, 539.563049316406);
    effector:SetKey(_TRACK_Y, 7.64, 41.3603668212891);
    effector:SetKey(_TRACK_X, 9.96, 560.563049316406);
    effector:SetKey(_TRACK_Y, 9.96, 34.8603668212891);
    effector:SetKey(_TRACK_SX, 0, 1.4);
    effector:SetKey(_TRACK_SY, 0, 1.4);
    effector:SetKey(_TRACK_SX, 9.96, 0.4);
    effector:SetKey(_TRACK_SY, 9.96, 0.4);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();


    -- Layer Layer_4
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Dino5_01.png');
    element:SetName('Layer_4');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(24.5625, 20);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(424.5, 407);

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

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

    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 0.8, -0.52519442698877);
    effector:SetKey(_TRACK_A, 1.36, -0.46089932239278);
    effector:SetKey(_TRACK_A, 1.8, -0.60499156806895);
    effector:SetKey(_TRACK_A, 2.24, -0.46089932239278);
    effector:SetKey(_TRACK_A, 2.64, -0.13172162589103);
    effector:SetKey(_TRACK_A, 3.36, -0.25760065717288);
    effector:SetKey(_TRACK_A, 4.68, 0.25635781748177);
    effector:SetKey(_TRACK_A, 6.16, -0.14175138743676);
    effector:SetKey(_TRACK_A, 7.84, 0.16331626654597);
    effector:SetKey(_TRACK_A, 9.96, 0);

    effector:Play();


    -- Layer Layer_5
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Dino4_01.png');
    element:SetName('Layer_5');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(16, 23.1875);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(321.5, 413);

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

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

    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.4, -0.31966939158339);
    effector:SetKey(_TRACK_A, 3, -0.11958273434513);
    effector:SetKey(_TRACK_A, 3.88, -0.28993470664597);
    effector:SetKey(_TRACK_A, 4.72, -0.57340792624048);
    effector:SetKey(_TRACK_A, 5.96, -0.04210897264977);
    effector:SetKey(_TRACK_A, 6.92, -0.19492927787803);
    effector:SetKey(_TRACK_A, 7.6, 0.18977630017491);
    effector:SetKey(_TRACK_A, 9.96, 0);

    effector:Play();


    -- Layer Layer_6
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Dino3_01.png');
    element:SetName('Layer_6');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(24.5, 15.3125);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(370, 413);

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

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

    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.16, 0.30600382419711);
    effector:SetKey(_TRACK_A, 2.36, 0.2457533223698);
    effector:SetKey(_TRACK_A, 3.12, 1.88703730587916e-9);
    effector:SetKey(_TRACK_A, 4.12, 0.09618630038082);
    effector:SetKey(_TRACK_A, 4.96, 1.47062922778013e-9);
    effector:SetKey(_TRACK_A, 7.64, 0.19630645366219);
    effector:SetKey(_TRACK_A, 8.64, 0.0391032010369);
    effector:SetKey(_TRACK_A, 9.96, 0);

    effector:Play();


    -- Layer Layer_7
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Dino2_01.png');
    element:SetName('Layer_7');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(38.6875, 16.25);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(640.5, 460);

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

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

    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.12, 0.21687361541859);
    effector:SetKey(_TRACK_A, 2.56, 0.13108361270343);
    effector:SetKey(_TRACK_A, 3.32, -0.16067868728836);
    effector:SetKey(_TRACK_A, 4.84, -0.1430451861791);
    effector:SetKey(_TRACK_A, 5.16, -0.07417670699018);
    effector:SetKey(_TRACK_A, 5.56, -0.08794478271612);
    effector:SetKey(_TRACK_A, 6.24, 0.30017487073718);
    effector:SetKey(_TRACK_A, 8.56, 0.27276358168782);
    effector:SetKey(_TRACK_A, 9.96, 0);

    effector:Play();


    -- Layer Layer_8
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Dino1_01.png');
    element:SetName('Layer_8');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(4.75, 31.8125);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(654.738739013672, 504.094589233398);

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

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

    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.68, 0.07126398659242);
    effector:SetKey(_TRACK_A, 2.76, -0.14261176761967);
    effector:SetKey(_TRACK_A, 4.56, 0.02411527234781);
    effector:SetKey(_TRACK_A, 5.96, -0.16607633573312);
    effector:SetKey(_TRACK_A, 7.04, 0.04652918080794);
    effector:SetKey(_TRACK_A, 8.32, -0.09159487504359);
    effector:SetKey(_TRACK_A, 9.96, 0);

    effector:Play();


    -- Layer Layer_9
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/EF_water01.jpg');
    element:SetName('Layer_9');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(168, 74);
    element:SetParentElement(compositionEnvBack);
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);

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

    effector:SetKey(_TRACK_X, 0, 562.085586547852);
    effector:SetKey(_TRACK_Y, 0, 423.860366821289);
    effector:SetKey(_TRACK_X, 1.08, 563.085586547852);
    effector:SetKey(_TRACK_Y, 1.08, 422.860366821289);
    effector:SetKey(_TRACK_X, 2.36, 561.585586547852);
    effector:SetKey(_TRACK_Y, 2.36, 422.360366821289);
    effector:SetKey(_TRACK_X, 3.72, 562.085586547852);
    effector:SetKey(_TRACK_Y, 3.72, 423.860366821289);
    effector:SetKey(_TRACK_X, 5.36, 561.585586547852);
    effector:SetKey(_TRACK_Y, 5.36, 423.360366821289);
    effector:SetKey(_TRACK_X, 6.96, 560.085586547852);
    effector:SetKey(_TRACK_Y, 6.96, 423.360366821289);
    effector:SetKey(_TRACK_X, 8.52, 561.085586547852);
    effector:SetKey(_TRACK_Y, 8.52, 423.860366821289);
    effector:SetKey(_TRACK_X, 9.96, 562.085586547852);
    effector:SetKey(_TRACK_Y, 9.96, 423.860366821289);
    effector:SetKey(_TRACK_O, 0, 0.4);
    effector:SetKey(_TRACK_O, 0.72, 0.6);
    effector:SetKey(_TRACK_O, 1.6, 0.2);
    effector:SetKey(_TRACK_O, 2.72, 0.6);
    effector:SetKey(_TRACK_O, 3.84, 0.2);
    effector:SetKey(_TRACK_O, 5.04, 0.6);
    effector:SetKey(_TRACK_O, 6.12, 0.1);
    effector:SetKey(_TRACK_O, 7.36, 0.6);
    effector:SetKey(_TRACK_O, 8.6, 0.2);
    effector:SetKey(_TRACK_O, 9.96, 0.4);

    effector:Play();


    -- Layer Layer_10
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/Layer_water01.png');
    element:SetName('Layer_10');
    compositionEnvBack:AddElement(element);
    element:SetHotSpot(109, 24);
    element:SetParentElement(compositionEnvBack);
    element:SetXY(586.364868164063, 456.648651123047);

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

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

    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 1.04, 0.8);
    effector:SetKey(_TRACK_O, 2.36, 0);
    effector:SetKey(_TRACK_O, 3.56, 0.8);
    effector:SetKey(_TRACK_O, 4.96, 0);
    effector:SetKey(_TRACK_O, 6.44, 0.8);
    effector:SetKey(_TRACK_O, 7.72, 0);
    effector:SetKey(_TRACK_O, 8.88, 0.8);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();

    compositionEnvBack:Play();

    return compositionEnvBack;
end

createCompositionEnvFront = function()

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


    -- Layer Layer_1
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/BF_[0-5].png');
    element:SetName('Layer_1');
    compositionEnvFront:AddElement(element);
    element:SetHotSpot(40, 24);
    element:SetParentElement(compositionEnvFront);
    element:SetAngle(0);

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

    effector:SetKey(_TRACK_X, 0, 852.18017578125);
    effector:SetKey(_TRACK_Y, 0, 826.810791015625);
    effector:SetKey(_TRACK_X, 0.52, 754.162155151367);
    effector:SetKey(_TRACK_Y, 0.52, 690.738723754883);
    effector:SetKey(_TRACK_X, 0.96, 682.666656494141);
    effector:SetKey(_TRACK_Y, 0.96, 671.135116577148);
    effector:SetKey(_TRACK_X, 1.52, 639.999984741211);
    effector:SetKey(_TRACK_Y, 1.52, 641.153137207031);
    effector:SetKey(_TRACK_X, 2.12, 586.954940795898);
    effector:SetKey(_TRACK_Y, 2.12, 621.549530029297);
    effector:SetKey(_TRACK_X, 2.56, 566.198181152344);
    effector:SetKey(_TRACK_Y, 2.56, 598.486465454102);
    effector:SetKey(_TRACK_X, 2.88, 556.972961425781);
    effector:SetKey(_TRACK_Y, 2.88, 560.432418823242);
    effector:SetKey(_TRACK_X, 3.24, 570.810806274414);
    effector:SetKey(_TRACK_Y, 3.24, 507.38737487793);
    effector:SetKey(_TRACK_X, 3.72, 592.720718383789);
    effector:SetKey(_TRACK_Y, 3.72, 469.33332824707);
    effector:SetKey(_TRACK_X, 4.08, 599.639633178711);
    effector:SetKey(_TRACK_Y, 4.08, 430.126113891602);
    effector:SetKey(_TRACK_X, 4.56, 575.423416137695);
    effector:SetKey(_TRACK_Y, 4.56, 395.531524658203);
    effector:SetKey(_TRACK_X, 5.08, 528.144134521484);
    effector:SetKey(_TRACK_Y, 5.08, 374.774765014648);
    effector:SetKey(_TRACK_X, 5.6, 475.099090576172);
    effector:SetKey(_TRACK_Y, 5.6, 372.468460083008);
    effector:SetKey(_TRACK_X, 5.96, 441.657653808594);
    effector:SetKey(_TRACK_Y, 5.96, 396.684677124023);
    effector:SetKey(_TRACK_X, 6.28, 422.054046630859);
    effector:SetKey(_TRACK_Y, 6.28, 427.819808959961);
    effector:SetKey(_TRACK_X, 6.76, 417.441436767578);
    effector:SetKey(_TRACK_Y, 6.76, 471.639633178711);
    effector:SetKey(_TRACK_X, 7.12, 389.765762329102);
    effector:SetKey(_TRACK_Y, 7.12, 490.090087890625);
    effector:SetKey(_TRACK_X, 7.44, 359.783782958984);
    effector:SetKey(_TRACK_Y, 7.44, 482.018020629883);
    effector:SetKey(_TRACK_X, 7.88, 332.108108520508);
    effector:SetKey(_TRACK_Y, 7.88, 455.495498657227);
    effector:SetKey(_TRACK_X, 8.4, 290.594589233398);
    effector:SetKey(_TRACK_Y, 8.4, 425.513519287109);
    effector:SetKey(_TRACK_X, 8.76, 237.549545288086);
    effector:SetKey(_TRACK_Y, 8.76, 419.747756958008);
    effector:SetKey(_TRACK_X, 9.08, 201.801803588867);
    effector:SetKey(_TRACK_Y, 9.08, 417.441452026367);
    effector:SetKey(_TRACK_SX, 0, 1);
    effector:SetKey(_TRACK_SY, 0, 1);
    effector:SetKey(_TRACK_SX, 0.96, 0.8);
    effector:SetKey(_TRACK_SY, 0.96, 0.8);
    effector:SetKey(_TRACK_SX, 2, 0.4);
    effector:SetKey(_TRACK_SY, 2, 0.4);
    effector:SetKey(_TRACK_SX, 3.36, 0.5);
    effector:SetKey(_TRACK_SY, 3.36, 0.5);
    effector:SetKey(_TRACK_SX, 5.08, 0.7);
    effector:SetKey(_TRACK_SY, 5.08, 0.7);
    effector:SetKey(_TRACK_SX, 6.76, 0.4);
    effector:SetKey(_TRACK_SY, 6.76, 0.4);
    effector:SetKey(_TRACK_SX, 9.08, 0.2);
    effector:SetKey(_TRACK_SY, 9.08, 0.2);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 8.76, 1);
    effector:SetKey(_TRACK_O, 8.88, 0);

    effector:Play();


    -- Layer Layer_2
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/DF1_[0000-0004].png');
    element:SetName('Layer_2');
    compositionEnvFront:AddElement(element);
    element:SetHotSpot(64, 48);
    element:SetParentElement(compositionEnvFront);
    element:SetOpacity(1);

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

    effector:SetKey(_TRACK_X, 0, 197.189193725586);
    effector:SetKey(_TRACK_Y, 0, 845.261276245117);
    effector:SetKey(_TRACK_X, 0.48, 219.099105834961);
    effector:SetKey(_TRACK_Y, 0.48, 718.414428710938);
    effector:SetKey(_TRACK_X, 0.76, 216.79280090332);
    effector:SetKey(_TRACK_Y, 0.76, 633.081100463867);
    effector:SetKey(_TRACK_X, 1.84, 208.79280090332);
    effector:SetKey(_TRACK_Y, 1.84, 628.581100463867);
    effector:SetKey(_TRACK_X, 1.96, 248.543317843608);
    effector:SetKey(_TRACK_Y, 1.96, 631.581100463867);
    effector:SetKey(_TRACK_X, 2.08, 275.29280090332);
    effector:SetKey(_TRACK_Y, 2.08, 628.581100463867);
    effector:SetKey(_TRACK_X, 3.68, 285.79280090332);
    effector:SetKey(_TRACK_Y, 3.68, 626.081100463867);
    effector:SetKey(_TRACK_X, 3.88, 241.543535502676);
    effector:SetKey(_TRACK_Y, 3.88, 618.831322009705);
    effector:SetKey(_TRACK_X, 4.08, 191.29280090332);
    effector:SetKey(_TRACK_Y, 4.08, 597.581100463867);
    effector:SetKey(_TRACK_X, 4.36, 271.79280090332);
    effector:SetKey(_TRACK_Y, 4.36, 652.581100463867);
    effector:SetKey(_TRACK_X, 4.68, 358.29280090332);
    effector:SetKey(_TRACK_Y, 4.68, 681.581100463867);
    effector:SetKey(_TRACK_X, 4.88, 398.042353924876);
    effector:SetKey(_TRACK_Y, 4.88, 669.581450273084);
    effector:SetKey(_TRACK_X, 4.961171875, 415.79280090332);
    effector:SetKey(_TRACK_Y, 4.961171875, 636.581100463867);
    effector:SetKey(_TRACK_X, 5.05859375, 440.29280090332);
    effector:SetKey(_TRACK_Y, 5.05859375, 623.081100463867);
    effector:SetKey(_TRACK_X, 5.156015625, 464.29280090332);
    effector:SetKey(_TRACK_Y, 5.156015625, 634.081100463867);
    effector:SetKey(_TRACK_X, 5.3021484375, 496.29280090332);
    effector:SetKey(_TRACK_Y, 5.3021484375, 643.081100463867);
    effector:SetKey(_TRACK_X, 5.46453125, 523.79280090332);
    effector:SetKey(_TRACK_Y, 5.46453125, 631.581100463867);
    effector:SetKey(_TRACK_X, 5.626875, 542.79280090332);
    effector:SetKey(_TRACK_Y, 5.626875, 612.581100463867);
    effector:SetKey(_TRACK_X, 6.76, 551.29280090332);
    effector:SetKey(_TRACK_Y, 6.76, 613.081100463867);
    effector:SetKey(_TRACK_X, 6.96, 651.294075763578);
    effector:SetKey(_TRACK_Y, 6.96, 603.830863370953);
    effector:SetKey(_TRACK_X, 7.16, 715.29280090332);
    effector:SetKey(_TRACK_Y, 7.16, 582.581100463867);
    effector:SetKey(_TRACK_X, 7.96, 710.29280090332);
    effector:SetKey(_TRACK_Y, 7.96, 573.581100463867);
    effector:SetKey(_TRACK_X, 8.2, 760.448137297596);
    effector:SetKey(_TRACK_Y, 8.2, 488.19217828441);
    effector:SetKey(_TRACK_X, 8.48, 810.29280090332);
    effector:SetKey(_TRACK_Y, 8.48, 284.581100463867);
    effector:SetKey(_TRACK_X, 9.44, 821.79280090332);
    effector:SetKey(_TRACK_Y, 9.44, 281.081100463867);
    effector:SetKey(_TRACK_X, 9.64, 828.86956355106);
    effector:SetKey(_TRACK_Y, 9.64, 156.002963229714);
    effector:SetKey(_TRACK_X, 9.96, 777.79280090332);
    effector:SetKey(_TRACK_Y, 9.96, -51.9188995361328);
    effector:SetKey(_TRACK_SX, 0, -1.2);
    effector:SetKey(_TRACK_SY, 0, 1.2);
    effector:SetKey(_TRACK_SX, 0.8, -1);
    effector:SetKey(_TRACK_SY, 0.8, 1);
    effector:SetKey(_TRACK_SX, 1.24, -1.1);
    effector:SetKey(_TRACK_SY, 1.24, 1.1);
    effector:SetKey(_TRACK_SX, 1.6, -0.9);
    effector:SetKey(_TRACK_SY, 1.6, 0.9);
    effector:SetKey(_TRACK_SX, 2.16, -1);
    effector:SetKey(_TRACK_SY, 2.16, 1);
    effector:SetKey(_TRACK_SX, 2.76, -0.8);
    effector:SetKey(_TRACK_SY, 2.76, 0.8);
    effector:SetKey(_TRACK_SX, 3.32, -1);
    effector:SetKey(_TRACK_SY, 3.32, 1);
    effector:SetKey(_TRACK_SX, 4.04, -0.9);
    effector:SetKey(_TRACK_SY, 4.04, 0.9);
    effector:SetKey(_TRACK_SX, 5.76, -0.5);
    effector:SetKey(_TRACK_SY, 5.76, 0.5);
    effector:SetKey(_TRACK_SX, 7.24, -0.4);
    effector:SetKey(_TRACK_SY, 7.24, 0.4);
    effector:SetKey(_TRACK_SX, 8.48, -0.6);
    effector:SetKey(_TRACK_SY, 8.48, 0.6);
    effector:SetKey(_TRACK_SX, 9.4, -0.7);
    effector:SetKey(_TRACK_SY, 9.4, 0.7);
    effector:SetKey(_TRACK_SX, 9.96, -0.9);
    effector:SetKey(_TRACK_SY, 9.96, 0.9);
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 0.76, 0.41662373479549);
    effector:SetKey(_TRACK_A, 1.32, 0.21532533349708);
    effector:SetKey(_TRACK_A, 1.64, 0.41333326635274);
    effector:SetKey(_TRACK_A, 2.04, 0.1369360737133);
    effector:SetKey(_TRACK_A, 2.76, 0.30706200503458);
    effector:SetKey(_TRACK_A, 3.28, 0.131301577055);
    effector:SetKey(_TRACK_A, 3.88, 0.51751035758953);
    effector:SetKey(_TRACK_A, 4.88, 0.16972965432424);
    effector:SetKey(_TRACK_A, 5.44, 0.40021096363693);
    effector:SetKey(_TRACK_A, 7.08, -0.0851897853908);
    effector:SetKey(_TRACK_A, 7.64, 0.44383822322641);
    effector:SetKey(_TRACK_A, 8.52, 0.18996718927719);
    effector:SetKey(_TRACK_A, 8.88, 0.38816033883741);
    effector:SetKey(_TRACK_A, 9.44, 0.28512505463982);

    effector:Play();


    -- Layer Layer_3
    local element = auxCreateCompositionElement('data/Texture/Scenes/19_DinoField/Animations/Env/EF_Light01.jpg');
    element:SetName('Layer_3');
    compositionEnvFront:AddElement(element);
    element:SetHotSpot(86, 76);
    element:SetParentElement(compositionEnvFront);
    element:SetXY(569.657653808594, 334.414413452148);

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

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

    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 1.12, 0.2);
    effector:SetKey(_TRACK_O, 2.12, 0.1);
    effector:SetKey(_TRACK_O, 2.92, 0.3);
    effector:SetKey(_TRACK_O, 3.84, 0.1);
    effector:SetKey(_TRACK_O, 4.6, 0.25);
    effector:SetKey(_TRACK_O, 5.6, 0);
    effector:SetKey(_TRACK_O, 6.68, 0.1);
    effector:SetKey(_TRACK_O, 7.48, 0.05);
    effector:SetKey(_TRACK_O, 8.48, 0.15);
    effector:SetKey(_TRACK_O, 9.96, 0);

    effector:Play();

    compositionEnvFront:Play();

    return compositionEnvFront;
end
