Jump to content

[SOLVED] Add big text to Screen


photo

Recommended Posts

Hi 

 

How do I display text that can change (get its value from a variable ) with this size using a ttf font; see images:

 

post-1284-0-90388100-1398758784_thumb.png

 

It MUST be allways in front of anything like setOrder(100); 

 

post-1284-0-49389600-1398758802_thumb.png

Link to comment
  • 2 weeks later...

Hi paul. Make sure that your widget was added in to gui later than other widgets. And yours widget will be always in front.

 

To change text or size using ttf font see the simple sample:

#include <unigine.h>

WidgetLabel label;
Gui gui;

float time = 0.0f;
float size = 15.0f;

int init() {
	
	gui = engine.getGui();
	
	label = new WidgetLabel(gui,"");
	label.setFontOutline(true);
	label.setFont("core/gui/fontbi.ttf");
	
	gui.addChild(label,GUI_ALIGN_CENTER);
	
	return 1;
}

int shutdown() {
	
	delete label;
	
	return 1;
}

int update() {
	
	float ifps = engine.game.getIFps();
	
	time += ifps;
	int s = time % 60.0f;
	int m = (time / 60.0f) % 60.0f;
	
	size = (size > 40.0f) ? 15.0f : size + ifps * 25.0f;
	
	label.setFontSize(ceil(size));
	label.setText(format("%i:%i",m,s));
	
	return 1;
}
Link to comment
×
×
  • Create New...