Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package effects;
- import flixel.FlxSprite;
- import flixel.system.FlxAssets.FlxGraphicAsset;
- import flixel.util.FlxColor;
- import flixel.tweens.FlxTween;
- import flixel.tweens.FlxEase;
- import flixel.math.FlxPoint;
- import registry.REG;
- /**
- * ...
- * @author Justin Cruz
- */
- class Tile extends FlxSprite{
- var floating:Bool = true;
- var state:GameState;
- var startPoint:FlxPoint;
- public var aY:Float = 4;
- public function new(?X:Float = 0, ?Y:Float = 0, State:GameState, ?Sprite:FlxSprite, ?Floating:Bool = true)
- {
- super(X, Y);
- floating = Floating;
- state = State;
- if (Sprite != null)
- {
- loadGraphicFromSprite(Sprite);
- angle = Sprite.angle;
- x = Sprite.x;
- y = Sprite.y;
- alpha = Sprite.alpha;
- alive = Sprite.alive;
- }
- startPoint = new FlxPoint(x, y);
- }
- override public function update(e:Float)
- {
- super.update(e);
- if (y > startPoint.y + aY)
- {
- velocity.y = 0;
- y = startPoint.y + aY;
- }
- if (y < startPoint.y)
- {
- velocity.y = 0;
- y = startPoint.y;
- }
- }
- //Sink
- public function startSink()
- {
- if (!alive)
- {
- FlxTween.manager.clear();
- velocity.y = REG.sinkSpeed;
- state.ripples.add(new Ripple(x - 48, y + 16, 2));
- FlxTween.color(this, 1 - ((y - startPoint.y) / 8), color, FlxColor.fromRGB(242, 242, 242, 255));
- alive = true;
- }
- }
- //Unskink
- public function floatUp()
- {
- if (alive)
- {
- FlxTween.manager.clear();
- velocity.y = -REG.sinkSpeed;
- FlxTween.color(this,((y - startPoint.y) / 8), color, FlxColor.WHITE);
- alive = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement