package ;

import flash.geom.Point;
import flash.geom.Rectangle;
import flixel.FlxSprite;
import flash.display.BitmapData;

class ClockSprite extends FlxSprite
{
	var startBitmapData:BitmapData;
	var endBitmapData:BitmapData;

	public var t(default,set):Float;

	public function new()
	{
		super(0,0);

		startBitmapData = openfl.Assets.getBitmapData("assets/images/Clock-Start.png");
		endBitmapData = openfl.Assets.getBitmapData("assets/images/Clock-End.png");

		makeGraphic(startBitmapData.width, startBitmapData.height, 0, true);
		drawFrame(true);

		t = 0;
	}

	function set_t(t_:Float)
	{
		t = t_;
		framePixels.copyPixels(startBitmapData, new Rectangle(0,0,startBitmapData.width,startBitmapData.height), new Point(0,0));
		var endRect = new Rectangle(0,0,startBitmapData.width,Std.int(startBitmapData.height * t));
		if (endRect.height != 0)
			framePixels.copyPixels(endBitmapData, endRect, new Point(0,0));
		return t_;
	}
}
