2267
« on: April 09, 2011, 10:14:57 am »
Here.
package scripts
{
import flash.display.BlendMode;
import flash.events.*;
import flash.net.*;
import flash.filters.*;
import Box2DAS.Collision.*;
import Box2DAS.Collision.Shapes.*;
import Box2DAS.Common.*;
import Box2DAS.Dynamics.*;
import Box2DAS.Dynamics.Contacts.*;
import Box2DAS.Dynamics.Joints.*;
import stencyl.api.data.*;
import stencyl.api.engine.*;
import stencyl.api.engine.actor.*;
import stencyl.api.engine.behavior.*;
import stencyl.api.engine.bg.*;
import stencyl.api.engine.font.*;
import stencyl.api.engine.scene.*;
import stencyl.api.engine.sound.*;
import stencyl.api.engine.tile.*;
import stencyl.api.engine.utils.*;
import org.flixel.*;
public dynamic class Design_4_4_DrawHUD extends SceneScript
{
public var _ItemstoDraw:Array;
public var _XOffset:Array;
public var _YOffset:Array;
public var _Font:Font;
public var _DrawHUD:Boolean;
public var _X:Number;
public var _Y:Number;
public var _ActorType:ActorType;
public var _ActorName:String;
public var _CreatedActorsList:Array;
public var _Actor:Actor;
override public function init():void
{
doesCustomDrawing();
if (_DrawHUD)
{
CreateActors();
}
}
override public function update():void
{
}
override public function draw(g:Graphics, x:Number, y:Number):void
{
if (_DrawHUD)
{
for (var index0:int = 0; index0 < _ItemstoDraw.length; index0 + +)
{
if ((String(("" + _ItemstoDraw[ index0])).indexOf("[Actor]") < 0))
{
g.translateToScreen();
g.setFont(_Font);
if (sameAs(("" + _XOffset[ index0]), "Center"))
{
_X = (getScreenX() + ((getScreenWidth() / 2) - (g.getFont().font.getTextWidth(("" + _ItemstoDraw[ index0])) / 2)));
}
else
{
_X = Number("" + _XOffset[ index0]);
}
if (sameAs(("" + _YOffset[ index0]), "Center"))
{
_Y = (getScreenY() + ((getScreenHeight() / 2) - (g.getFont().font.height / 2)));
}
else
{
_Y = Number("" + _YOffset[ index0]);
}
g.drawString("" + ("" + _ItemstoDraw[ index0]), _X, _Y);
}
}
}
}
/*IGNORE __Index __Item */
public function AddtoHUDList(__Index:Number, __Item:Object):void
{
_ItemstoDraw[ __Index] = __Item;
}
/*IGNORE __Index */
public function RemoveHUDElement(__Index:Number):void
{
ArrayUtil.removeAt(_ItemstoDraw, __Index);
}
public function StartDrawingHUD():void
{
_DrawHUD = true;
CreateActors();
}
public function StopDrawingHUD():void
{
_DrawHUD = false;
for each(var item:* in _CreatedActorsList)
{
setValueForScene("Draw HUD", "_Actor", item);
if ((_Actor ! = null && _Actor.isAlive()))
{
_Actor.die();
}
}
}
public function CreateActors():void
{
for (var index0:int = 0; index0 < _ItemstoDraw.length; index0 + +)
{
if ((String(("" + _ItemstoDraw[ index0])).indexOf("[Actor]") > = 0))
{
_ActorName = String(("" + _ItemstoDraw[ index0])).substring((String(("" + _ItemstoDraw[ index0])).indexOf("]") + 1), String(("" + _ItemstoDraw[ index0])).length);
_ActorType = getActorTypeByName(_ActorName);
if (_ActorType ! = null)
{
createActor(_ActorType, Number("" + _XOffset[ index0]), Number("" + _YOffset[ index0]), FRONT);
getLastCreatedActor().anchorToScreen();
_CreatedActorsList.push(getLastCreatedActor());
}
}
}
}
public function Design_4_4_DrawHUD(ignore:*, scene:GameState)
{
super(scene);
}
override public function forwardMessage(msg:String):void
{
}
}
}