Oh yes of course.
This is the code to calculate the raypoints that later forms the shape of the light:
public function rays(flashAng:Number, flashStep:Number):Vector.<Point>
{
var angle:Number = FP.angle(Player.pos.x, Player.pos.y, x, y) - flashAng * 0.5;
var rays:Vector.<Point> = new Vector.<Point>;
rays.push(Player.pos);
for (var i:int = 0; i <= flashStep; i++)
{
angle += flashAng/flashStep;
var rayPoint:Point = new Point();
var tmpPoint:Point = new Point();
FP.angleXY(tmpPoint, angle, dist, Player.pos.x, Player.pos.y);
if (FP.world.collideLine("level", Player.pos.x, Player.pos.y, tmpPoint.x, tmpPoint.y, 1, rayPoint))
{
FP.angleXY(rayPoint, angle, 24, rayPoint.x, rayPoint.y);
rays.push(rayPoint);
}
else {
rays.push(tmpPoint);
}
}
return rays;
}
And this is the code to draw the polygon:
public function calcSight(rays:Vector.<Point>):FXImage
{
FP.sprite.graphics.clear();
FP.sprite.graphics.beginFill(0x333333, 1);
var p:Point = new Point();
for each (p in rays)
{
if (p == Player.pos)
{
var p1:Point = new Point();
var len:Number = FP.distance(Player.pos.x - dist, Player.pos.y - dist, p.x, p.y);
var ang:Number = FP.angle(Player.pos.x - dist, Player.pos.y - dist, p.x, p.y);
FP.angleXY(p1, ang, len);
FP.sprite.graphics.moveTo(p1.x, p1.y);
}
else {
var p2:Point = new Point();
var len2:Number = FP.distance(Player.pos.x - dist, Player.pos.y - dist, p.x, p.y);
var ang2:Number = FP.angle(Player.pos.x - dist, Player.pos.y - dist, p.x, p.y);
FP.angleXY(p2, ang2, len2);
FP.sprite.graphics.lineTo(p2.x, p2.y);
}
}
FP.sprite.graphics.endFill();
var data:BitmapData = new BitmapData(dist * 2, dist * 2, true, 0xffffff);
data.draw();
var img:FXImage = new FXImage(data);
img.color = 0x000000;
img.alpha = 1;
return img;
}
The I use the lit-libary that post in the forum, it basicly performs an alpha blending over the seen screen.
Maybe you can find some fixes! And really thanks that somebody is interested to help my beginner problems!