Source

ld3k / Panel.as

Full commit
package
{
	import net.flashpunk.Entity;
	import net.flashpunk.Graphic;
	import net.flashpunk.Mask;
	import net.flashpunk.graphics.Spritemap;
	
	public class Panel extends Entity
	{
		[Embed(source = 'data/panel.png')]
		public static const ImgPanel:Class;
		
		private var showarr:Array = [
			-12, -10, -8, -6, -4, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
			 -2,  -4, -8, -10, -12,
		];
		
		public var spr:Spritemap;
		private var _showix:int = 0;
		private var _show:Boolean = false;
		private var _persistshow:Boolean = false;
		
		public function Panel()
		{
			spr = new Spritemap(ImgPanel, 96, 12);
			super(0, -12, spr);
		}
		
		public function show(Frame:int, Persist:Boolean):void
		{
			_show = true;
			_persistshow = Persist;
			_showix = 0;
			spr.frame = Frame;
		}
		
		override public function update():void
		{
			if (_show) {
				y = showarr[_showix++];
				if (_persistshow && _showix >6) _show = false;
				else if (_showix == showarr.length) _show = false;
			}
			super.update();
		}
	}
}