pAge = Allocate(1) ; -- Allocate a parameter representing age.
pVelocity = Allocate(2)
-- Set the particle texture
SetTexture("star.xml");
SetBlendMode(kBlendAdditiveAlpha);

SetNumParticles(500);    -- Create some particles
pVelocity:Init( f2dRadius( 60) * fRange( 1.5,3.5));
if not dPos then
  dPos = Vec2( 0, 0)
end
pPosition:Init( f2dRadius( 60 )  * fRange( 0.4, 0.6 ) + dPos);
pColor:Init( Color(1,1,1,1) );
pScale:Init( fRange( 0.7, 1.2 ) );
pUp:Init( f2dRadius( 1 ) );   -- random radius
pAge:Init( 0 ) ;

-- Fade the particles.

pAge:Anim( pAge+fAge() );
pColor:Anim( fFade( pAge, Color(1,1,1,1), 1000, Color(0,0,0,0) ) );
pPosition:Anim( pPosition + fTimeScale( pVelocity) );
-- Expire particles which faded out completelly.

Anim(  fExpire(  fLess( pColor[ 3 ], 0.001 )  )  ) ;

-- A function to run as we're executing
-- seconds - how many seconds have elapsed
gActive = false;
function Update(seconds)
   -- Create 20 particle per second
   if gActive then
      CreateParticles( seconds * 500 );
   end
end

