# I have a lens flare effect that I want to animate....and not respond to the mouse

**URL:** <https://forum.kirupa.com/t/i-have-a-lens-flare-effect-that-i-want-to-animate-and-not-respond-to-the-mouse/247677>\
**Category:** Uncategorized\
**Created:** [December 28, 2007, 1:00am UTC](https://forum.kirupa.com/t/i-have-a-lens-flare-effect-that-i-want-to-animate-and-not-respond-to-the-mouse/247677 "2007-12-28T01:00:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtrace](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@dtrace](https://forum.kirupa.com/u/dtrace)\
**Post date:** [December 28, 2007, 1:00am UTC](https://forum.kirupa.com/t/i-have-a-lens-flare-effect-that-i-want-to-animate-and-not-respond-to-the-mouse/247677/1 "2007-12-28T01:00:27Z")

</div>

I’m using a lens flare…that follows the user’s mouse…but I want to animate it so that it goes from the left side of the screen to the right.

It currently uses…

flare.\_x = \_xmouse;  
flare.\_y = \_ymouse;

and it just cycles on this using…  
prevFrame();  
play();

What would be the best way to animate it…?

Thanks.

and this is how it works…  
var x;  
var y;  
var angle;  
var radius;  
var big\_alpha = 0;  
function placeObject (object, expand)  
{  
// The higher expand is set, the more it will stretch-out from the center  
// as the light moves from the center.  
object.\_x = (radius \* expand) \* Math.cos(angle);  
object.\_y = (radius \* expand) \* Math.sin(angle);  
}

and on the next frame…  
radius = Math.sqrt(\_x\*\_x+\_y\*\_y);  
angle = Math.atan(\_y/\_x);  
// Correct angle for quadrant.  
if (\_x \< 0) angle = (Math.PI) + angle;  
burst1.\_x = x;  
burst2.\_y = y;  
placeObject(burst2, 1);  
placeObject(burst3, 0.5);  
placeObject(burst4, 1.8);  
placeObject(burst5, 0.6);  
placeObject(burst6, 1.5);  
placeObject(burst7, -0.4);  
placeObject(burst8, 1.6);  
placeObject(burst9, -0.2);  
// Closer to the center, the more alpha there is.  
big\_alpha = 100 - radius;  
if (big\_alpha \< 0) big\_alpha = 0;  
bigburst.\_alpha = big\_alpha;
