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

Get help using Construct 2

Post » Thu Apr 13, 2017 12:57 am

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.
B
22
S
5
G
1
Posts: 43
Reputation: 1,734

Post » Thu Apr 13, 2017 6:52 am

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.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Apr 13, 2017 2:00 pm

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!
B
22
S
5
G
1
Posts: 43
Reputation: 1,734

Post » Thu Apr 13, 2017 9:37 pm

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.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Fri Apr 14, 2017 9:21 pm

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
Last edited by 99Instances2Go on Wed Aug 09, 2017 8:05 pm, edited 1 time in total.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Apr 17, 2017 5:58 pm

Wow! This is exactly what I was going for. Thanks so much taking the time to help me out with this! <3
B
22
S
5
G
1
Posts: 43
Reputation: 1,734


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests