Panels and Huds

Blitz3D Forums/Blitz3D Beginners Area/Panels and Huds

Depends what you're trying to achieve.

Probably your best bet is to create a single surface text routine. However, this is hardly a topic for the begninners area.

2D overlay can have problems with certain 3D cards, so if you're planning on releasing this for cash then you'll probably want to avoid.

Sprites are a nice easy option, this is the option I'd choose for the Beginners area. The downside is that every sprite will use it's own surface so it's not a great technique, however, it's one to use so you can move into the more complex single surface stuff...

Heres one I did a couple of years back...

Basically the font is a single anim image.
The font$ is the list of characters in order in the image.

You then send the new_word function the x,y,words,rgb as a 3 letter hex string (FFF for white F00 for red etc), size of font, if it's centred, and it's alpha value.

As you'll notice the sprites are always at a z of 0, this is because a second camera would be used to render this lot.

Then you've got the final clear_letters function that you use to wipe the letter type out so you can redraw stuff again.

Global fon_text=LoadAnimTexture("gfx\font.png",52,8,8,0,41)

Type letter
	Field mesh
End Type

Function new_word(x#,y#,char$,rgb$="FFF",size#=.2,centre=0,alpha#=1)
	font$="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.,- "
	hexy$="0123456789ABCDEF"
	If centre=1 Then x=x-(Float(Len(char))/2)*(size*2)
	If centre=2 Then x=x-Float(Len(char))*(size*2)
	For n=1 To Len(char)
	l.letter= New letter
	l\mesh=CreateSprite()
	ScaleSprite l\mesh,size,size
	PositionEntity l\mesh,x,y,0
	EntityTexture l\mesh,fon_text,Instr(font,Mid(char,n,1))-1
	EntityColor l\mesh,Instr(hexy,Mid(rgb,1,1))*16,Instr(hexy,Mid(rgb,2,1))*16,Instr(hexy,Mid(rgb,3,1))*16
	x=x+(size*2)
	EntityAlpha l\mesh,alpha
	EntityOrder l\mesh,-11
	Next
End Function
	
Function clear_letters()
	For current.letter = Each letter
	FreeEntity current\mesh
	Delete current
	Next
End Function