Graphiclist is not displaying my Text [SOLVED]


(matt nesbary) #1

[SOLVED] I started working on an old game again moved from flashpunk 1.4 / flex 3.2 to vers 1…7 / 4.6, everything was working except my Text that I put in graphiclist wont display - graphic list shows my health bars other graphics … and I can do hello world text… I cant figure out why this wont show up. Here is my code:

The Text not working is “infotext”

package
{ import flash.display.Bitmap; import net.flashpunk.Entity; import net.flashpunk.FP; import net.flashpunk.; import net.flashpunk.graphics.; import net.flashpunk.graphics.Graphiclist; import net.flashpunk.utils.*; import flash.geom.Point; import net.flashpunk.graphics.Text; import net.flashpunk.utils.Input; import net.flashpunk.utils.Key;

public class HUDscore extends Entity
{
	[Embed(source = "/assets/nokiafc22.ttf", fontFamily = "nokiafc22")] private var font:Class;
	
	
	[Embed(source = "/assets/Hudbar.png")] private var spr_hudbar:Class;
	[Embed(source = "/assets/HShield.png")] private var spr_shields:Class;
	[Embed(source = "/assets/HArmor.png")] private var spr_armor:Class;
	[Embed(source = "/assets/Healthbar.png")] private var spr_bar:Class;
	private static var armor:Image;	
	private static var shields:Image;	
	private static var bar:Image;	

	
	//------------------- Info
	public static var infotext:Text;
	
	public static var score:Number = 0;
	private var scoreText:Text = new Text(String(score), 10, 8 , 200, 50);
	
	//---------------- Gui Stuff
	private static var hudbar:Image;	
	private var display:Graphiclist;
	

	public function HUDscore() 
	{
		layer = -7
		hudbar = new Image(spr_hudbar)	
		

		//------------------------------------------------------------------------------------ 
		//                                         HEALTH BARS
		//------------------------------------------------------------------------------------
		//  Shields / Armor / Health
		// if (HAupframeON = 1)   { shield = new image(spr_shields)
		shields = new Image(spr_shields)	
		shields.y = 326
		
		armor = new Image(spr_armor)	
		armor.y = 349
		
		bar = new Image(spr_bar)	
		bar.y = 368


		// note  X positions must be set in overide public function to adjust for camera movement
		//------------------------------------ info
		infotext = new Text("INFORMATION TEXT if you can read this.. shit FINALLY fucking works",90,260,200,280);
		infotext.font = "nokiafc22"
		infotext.color = 0x878BAD;
		infotext.size = 16
		//--------------------------- Score
		scoreText.font = "nokiafc22"
		scoreText.color = 0x6B6B6B;
		scoreText.size = 20


		//  graphic = new Text("Hello World!"); -- this works
		//------------------------ Make everything show up on screen! - infoText,scoreText
		display = new Graphiclist(bar, armor, shields,scoreText, infotext);
		graphic = display;
	}
	
	
	override public function update():void
	{
		//-----------------------------------------------------------  Adjustments HUD elements for camera movement 
		hudbar.x = 0 + FP.camera.length;
		shields.x = 12 + FP.camera.length;
		armor.x = 12 + FP.camera.length;
		bar.x = 12 + FP.camera.length;
		
		infotext.x = 200 + FP.camera.length;
		


		//---------------------------------------------------------  Game Over  :(
		if (Input.check(Key.ENTER))
		{
			graphic = new Text("Hello World!",90,260,200,280);  // this works 
			score = 0;

		}		
		
	}
	
}

}


(Jacob Albano) #2

Is it because you’re positioning your text at (90, 260) and it’s just being adjusted too far off the screen?

Or is it maybe that “nokiafc22” doesn’t refer to a font that’s been embedded properly?


(matt nesbary) #3

Thanks! It was the embedding because I went from flex 3 -> flex 4 I needed to change

public class HUD extends Entity
{
	[Embed(source = "/assets/nokiafc22.ttf", fontFamily = "nokiafc22")] 
	private var font:Class;

to

	[Embed(source = "/assets/nokiafc22.ttf", embedAsCFF = "false", fontFamily = "nokiafc22")]
	 private const font:Class;