Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import flixel.FlxG;
- import flixel.FlxSprite;
- import flixel.math.FlxPoint;
- import flixel.util.FlxColor;
- import states.StateGameplay;
- /**
- * ...
- * @author ORL
- */
- class Light extends FlxSprite
- {
- private var _follow:FlxSprite;
- public var enabled:Bool;
- public var switchable:Bool = false;
- public var _scale:Float = 1;
- public function new(x:Float, y:Float, ?img:String, ?follow:FlxSprite, ?Switchable:Bool = false, ?Scale:Float = 1)
- {
- super(x, y);
- _follow = follow;
- switchable = Switchable;
- _scale = Scale;
- loadGraphic(img);
- this.blend = openfl.display.BlendMode.SCREEN;
- antialiasing = false;
- width = width *LightManager.RESOLUTION;
- height = height * LightManager.RESOLUTION;
- scale.x = scale.x /2* Scale;
- scale.y = scale.y / 2*Scale;
- centerOffsets();
- }
- public function getXY():FlxPoint
- {
- if (_follow != null)
- {
- var pscreenXY:FlxPoint = _follow.getScreenPosition();
- return new FlxPoint(pscreenXY.x - width / 2 + _follow.width / 2, pscreenXY.y - height / 2 + _follow.height / 2);
- }
- else
- {
- return getScreenPosition();
- }
- }
- override public function update(elapsed:Float):Void
- {
- super.update(elapsed);
- //enabled = _follow.isOnScreen();
- enabled = false;
- if ( Utils.getDistance(StateGameplay.instance.player.getMidpoint(), _follow.getMidpoint()) <= 900)
- {
- enabled = true;
- }
- if (!switchable)
- enabled = true;
- if(switchable)
- if (FlxG.keys.justPressed.M)
- {
- alive = !alive;
- }
- alpha = StateGameplay.instance.darkness.alpha*1.4;//1.8
- //alpha = 1;//1.8
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement