/Flash project/src/com/danta/radialFortress/components/ShieldMeter.as
ActionScript | 137 lines | 46 code | 21 blank | 70 comment | 3 complexity | 6f42c0459a5db5ee7c0958f43d1956b1 MD5 | raw file
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Zemoga Inc
- // Copyright 2011 Zemoga Inc
- // All Rights Reserved.
- //
- ////////////////////////////////////////////////////////////////////////////////
- package com.danta.radialFortress.components
- {
- import flash.display.Sprite;
-
-
- /**
- * Class description here
- *
- * @author camilosoto <email>
- */
- public class ShieldMeter extends Sprite
- {
- //------------------------------------------------------------------------------
- //
- // Constants
- //
- //------------------------------------------------------------------------------
-
- //--------------------------------------
- // Public
- //--------------------------------------
-
- //--------------------------------------
- // Private
- //--------------------------------------
-
- //------------------------------------------------------------------------------
- //
- // Static Methods
- //
- //------------------------------------------------------------------------------
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Constructor
- //
- ////////////////////////////////////////////////////////////////////////////////
-
- public function ShieldMeter()
- {
- shieldLabel=new ShieldLabel();
- this.addChild(shieldLabel);
- piecesContainer = new Sprite();
- piecesContainer.x = shieldLabel.width+10;
- this.addChild(piecesContainer);
- createPieces();
- }
-
- //------------------------------------------------------------------------------
- //
- // Variables
- //
- //------------------------------------------------------------------------------
-
- private var shieldLabel:ShieldLabel;
- private var piecesContainer:Sprite;
- private var pieces:Array;
-
- //--------------------------------------
- // Public
- //--------------------------------------
-
- //--------------------------------------
- // Private
- //--------------------------------------
-
-
- //------------------------------------------------------------------------------
- //
- // Properties (getters/setters)
- //
- //------------------------------------------------------------------------------
-
- //------------------------------------------------------------------------------
- //
- // Overriden methods
- //
- //------------------------------------------------------------------------------
-
- //------------------------------------------------------------------------------
- //
- // Methods
- //
- //------------------------------------------------------------------------------
-
- //--------------------------------------
- // Public
- //--------------------------------------
-
- public function setHealth(health:int):void
- {
- for(var i:int=0; i<Ship.MAX_HEALTH;i++)
- {
- if(i<health)
- {
- pieces[i].visible=true;
- }
- else
- {
- pieces[i].visible=false;
- }
- }
- }
-
- //--------------------------------------
- // Private
- //--------------------------------------
-
- private function createPieces():void
- {
- pieces=[];
- var piece:ShieldPiece;
- for(var i:int=0; i<Ship.MAX_HEALTH;i++)
- {
- piece=new ShieldPiece();
- piece.x=i*(piece.width-5);
- piece.y=5;
- piecesContainer.addChild(piece);
- pieces.push(piece);
- }
- }
-
- //------------------------------------------------------------------------------
- //
- // Event Handlers
- //
- //------------------------------------------------------------------------------
-
- }
- }