, Sr. Member
This is the very very simple HUD code, and must be corrected but works !
[Embed(source=“resources/Contagiri1.png”)]private var ContagiriImg:Class;
[Embed(source=“resources/Contachilometri.jpg”)]private var ContachilometriImg:Class;
// BITMAP CONTAGIRI
private var PowerBitmap:Bitmap;
// DATI BITMAP BARRA ENERGIA ATTORE
private var bdataPower:BitmapData;
// RIEMPIMENTO BARRA ENERGIA ATTORE
private var ActorPower:Shape = new Shape();
//——————————————————————————————————————————————————————-
// RESTART GAME
//——————————————————————————————————————————————————————-
private function CreaContagiri():void
{
//
bdataPower = new BitmapData( 200, 200, true, 0x000000 );
bdataPower.copyPixels( new ContagiriImg().bitmapData,
new Rectangle( 0, 0, 200, 200 ),
new Point(), null, null, false );
ActorPower.graphics.lineStyle( 4, 0xFF0000, 1 );
ActorPower.graphics.beginFill( 0x00ff00 );
ActorPower.graphics.moveTo( 100, 100 );
ActorPower.graphics.lineTo( 100 + ( 60 * Math.sin( 240 * DEGREES_TO_RADIANS ) ), 100 - ( 60 * Math.cos( 240 * DEGREES_TO_RADIANS ) ) );
ActorPower.graphics.endFill();
//
bdataPower.draw( ActorPower );
//
PowerBitmap = new Bitmap( bdataPower );
//
PowerBitmap.name = “Contagiri”;
//
PowerBitmap.alpha = 0.4;
//
stage.addChild( PowerBitmap );
//
//PowerBitmap.y = 162.0;
}
//——————————————————————————————————————————————————————-
// CALCOLA E VISUALIZZA POSIZIONE GIOCATORE NELLA MAPPA
//——————————————————————————————————————————————————————-
public function AggiornaContagiri():void
{
var GP:Number = 240.0;
GP += ( 200.0 / ( CCarAI1.LimGiri0 - CCarAI1.LimGiri1 ) ) * CCarAI1.Giri;
//
var bd:BitmapData = new BitmapData( 200, 200, true, 0x000000 );
bdataPower.copyPixels( new ContagiriImg().bitmapData,
new Rectangle( 0, 0, 200, 200 ),
new Point(), null, null, false );
//
ActorPower.graphics.clear();
ActorPower.graphics.lineStyle( 4, 0xFF0000, 1 );
ActorPower.graphics.beginFill( 0x00ff00 );
ActorPower.graphics.moveTo( 100, 100 );
ActorPower.graphics.lineTo( 100 + ( 60 * Math.sin( GP * DEGREES_TO_RADIANS ) ), 100 - ( 60 * Math.cos( GP * DEGREES_TO_RADIANS ) ) );
ActorPower.graphics.endFill();
//
bdataPower.draw( ActorPower );
//
PowerBitmap = new Bitmap( bdataPower );
//
// PowerBitmap.y = 162.0;
}