Dev Log: Some Bitmap Text
I guess I'll start calling these posts Dev Logs now? Yeah, that sounds good.
The latest thing I've been chipping away at is handling bitmap text in my Flashpunk extended framework thing. There have been a couple of people that have posted Bitmap Font classes but they didn't do what I wanted, and I'm way better at coding my own thing from scratch vs. trying to modify someone else's code to do what I want.
Right now my bitmap text secret technology can do some cool stuff, like three different align modes (left, center, and right) which sounds pretty simple but it actually took me awhile to think of the proper solution for lining up text in a certain way. I also have some colored text as you can see in that awesome screenshot, and the way I do that is pretty cool (I think.) My code for coloring text ends up looking something like this:
You can see a little bit how it works. I can define colors, which are assigned to certain characters (any Ascii character can be used) and then I can mark colors with a special character like '#'. Text after that character will then be drawn with a tint of that color. It's super easy to do colored words with this system, but it makes some other stuff pretty difficult.
One thing I still haven't figured out is how to escape the special character. Like if I wanted to actually display a '#' in my string, I don't have a way of doing that right now. I wanted to have '##' just escape out to a '#', and I was trying some fancy stuff with regular expressions for awhile but... yeah, things have not worked out yet. This is something I can probably just tackle later though.
Bitmap text comes in handy for a few reasons, and I think I'll make a more detailed blog post about that at some point down the road!
The latest thing I've been chipping away at is handling bitmap text in my Flashpunk extended framework thing. There have been a couple of people that have posted Bitmap Font classes but they didn't do what I wanted, and I'm way better at coding my own thing from scratch vs. trying to modify someone else's code to do what I want.
Right now my bitmap text secret technology can do some cool stuff, like three different align modes (left, center, and right) which sounds pretty simple but it actually took me awhile to think of the proper solution for lining up text in a certain way. I also have some colored text as you can see in that awesome screenshot, and the way I do that is pretty cool (I think.) My code for coloring text ends up looking something like this:
//make da bitmap text
var bmpText:BitmapText = new BitmapText("This text will be #1GREEN!!#0 Yeah.", Global.bitmapFont);
//define the color "1" as green
bmpText.defineColor("1", 0x00FF00);
You can see a little bit how it works. I can define colors, which are assigned to certain characters (any Ascii character can be used) and then I can mark colors with a special character like '#'. Text after that character will then be drawn with a tint of that color. It's super easy to do colored words with this system, but it makes some other stuff pretty difficult.
One thing I still haven't figured out is how to escape the special character. Like if I wanted to actually display a '#' in my string, I don't have a way of doing that right now. I wanted to have '##' just escape out to a '#', and I was trying some fancy stuff with regular expressions for awhile but... yeah, things have not worked out yet. This is something I can probably just tackle later though.
Bitmap text comes in handy for a few reasons, and I think I'll make a more detailed blog post about that at some point down the road!
4 Comments