How do I display text with each character its own instance?

  • Hello,

    So my question is basically this:

    Imagine that you have a paragraph of text. You play as a block that can run and jump. Whenever you collide with the paragraph of text, whatever characters you touch instantly get destroyed, but the rest of the paragraph remains visible and intact.

    I have been attempting to use Rex's Layouter plugin and all its relevant behaviors to display a textbox object (NOT a text object), but I don't believe line breaks are possible even when the textbox type is "typearea."

    The methods I can think of would be extremely tedious, such as using a sprite font and storing the paragraph of text in an array, then creating an instance of the sprite font for each character in the paragraph and placing them by code instead of C2 doing it automatically.

  • Positioning by code is much less tedious than you might imagine. Breaking up a string into it's constituent characters into an array is just one single looped event, and placing them all as sprites again is another.

    It gets more complicated when dealing with individual spacing between characters (depending on the width of the character) and line breaks. Those can be handled based on your requirements though.

    Sorry don't have an example for you right now but if you have trouble figuring it out and don't mind waiting I can put one together pretty quick when I get to a computer tomorrow.

  • That would be amazing, oosyrag. I have spent more time than I care to admit trying to get this nailed down. I will continue to take your methods as you described and try to come up with something, but if you do get the chance to throw together a simple example, I would be forever in your favor for it.

    Thanks!

  • https://www.dropbox.com/s/mvv1sihhfe9mh ... .capx?dl=0

    As you can see there is work to be done regarding character spacing, but I did add in line breaks for you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • oosyrag's method, with a spritefont. Takes care of all spacing problems.

    https://www.dropbox.com/s/pulicbu30406c ... .capx?dl=0

    Actual not that difficult, but hard to find a spritefont that is not behind a paywall.

    Copyrighting things for this non-commercial used spritefont, you find here:

    https://www.scirra.com/tutorials/629/sp ... ere/page-1

  • Wow! This is exactly what I was going for. Thanks so much taking the time to help me out with this! <3

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)