-- Additional parameters
pAge = Allocate(1);
pVelocity = Allocate( 2 ) ;
pSpin = Allocate( 1 );
pSpinSpeed = Allocate( 1 );
-- Set the particle texture
SetTexture("leaves_local.xml");
SetBlendMode(kBlendNormal);

-- Create some particles
SetNumParticles(6);    -- Create some particles

-- Init Particles
pPosition:Init( fRange(Vec2(-80,-10), Vec2(80,10))); -- initial position
pColor:Init( Color(1,1,1,1) ); -- blending color
pVelocity:Init( fRange( Vec2( -10, 15 ), Vec2( 10, 25 ) ) ) ; -- random velocity
pSpin:Init( fRange( 0, 2*3.1415927 ) ); -- random orientation
pSpinSpeed:Init( fRange( 1, 3 ) ); -- random spin speed
pUp:Init( f2dRadius( pSpin ) );   -- random radius
pFrame:Init( fPick(0,1,2,3,4) );


-- Move the particles
-- define the movement

-- update movement
pAge:Anim( pAge + fAge() );
pPosition:Anim( pPosition + fTimeScale( pVelocity + pUp * 50)); -- position update  40 scale the speed
pSpin:Anim( pSpin + fTimeScale( pSpinSpeed) ); -- spin update
pUp:Anim( f2dRotation( pSpin) ); -- particle orientation
pColor:Anim( fFade( pAge, Color(1,1,1,0.8), 9000, Color(1,1,1,1),11000, Color(0.1,0.1,0.1,0.01)));
-- Expire particles lower than 600
Anim( fExpire( fGreater(pAge,  12000) ) );

-- intial
CreateParticles( 1 );
-- A function to run as we're executing
-- seconds - how many seconds have elapsed


-- USE THIS TO CHANGE THE AMOUNT OF LEAVES
LeavesPerSecond = 0.1;

function Update(seconds)
   -- Create 10 particles per second
   CreateParticles( seconds * LeavesPerSecond );
end

