Since the official sprite font plugin was released, there's a function I've used in almost every project I've worked on that parses a string into individual lines based on a maximum line width, and the character widths of a sprite font object. Basically, the function takes a string, breaks it down into individual lines, and add the lines to an array. I've found the function most useful when implementing dialog systems. Knowing the exact width and height of each line of text allows for much smoother dialog effects. Here are two example:
Dialog at top or bottom of screen
Dialog for specific sprites
Here's a capx with the parsing function used in the above examples:
Capx (Updated to v2 on 12/12/13)
Please note, manually adding newlines to text is not currently supported.
Hopefully someone else finds this function useful as well.
Very cool. I'll look into your code in a second!
Develop games in your browser. Powerful, performant & highly capable.
Is is possible to post a v146 capx? Thanks!
There's nothing in the capx that uses features beyond v146. You should be able to open the capx using file compression software (e.g. 7-zip) and revert it back to v146.
That's pretty slick. I'm going to try it in an upcoming project. Thank you for posting.