Is it possible to have a different color text border with flashpunk? In HTML5, for example, I would just call fillText() and then strokeText() with another color to achieve that. What is the simpliest way to do it in flash?
Text border / outline
As far as Flash goes, it’s totally possible to have a font with all kinda’ crazy filters (strokes, fills, gradients, drop shadows, et cetera); however, FlashPunk works with pixels, so filters aren’t as easy.
You can work with rich text and set styles to a Text
(which adhere to Adobe’s TextField.StyleSheet
standards), or you can look into applying a BitmapFilter
to your Text
which can simulate a border.
Or, you could fake it by making a border colored text a bit larger than your standard text and layering them on top of one another (but this doesn’t look great always).
Thanks for showing the right direction, I’ll read more about this solutions. Faking the border with another, larger text could be good as a shadow text, but not for a regular border I think, as the symbols of those two texts can easily go out of position (especially for longer texts).
You can use a Glow filter to add a really strong with not much blur to fake an outline. Just fiddle with the values!
Maybe someone will be interested in it - I found a way to fake the border with pure Flashpunk Text class: draw 4 additional texts with border color and the same size, but slightly moved - assuming that you want 2-pixel border the offsets would be [(-2, -2), (2, -2), (2, 2), (-2, 2)] (diagonally in each direction). Works quite good in most cases.
At my game I just used 2 textes with 2 different fonts.1 the actualy font and the other the border.It worked like a charm.