Display text character by character with bitmap font

Post your own tutorials, guides and demos.

Post » Sat Nov 15, 2008 2:51 am

If I'm not mistaken something like the Text Blitter extension from MMF is already requested for Construct. And I'm really looking forward to this. But in the meantime I came up with my own workaround. I don't think it's very elegant, but works on a basic level.

Just try the cap. You can type any text inside the edit box and by clicking on the "Text it!" button it will be displayed character by character in a custom bitmap font. Well not ANY text, since I only included the letters from A-Z. Full stop, comma, exclamation mark and question mark will work as well. No other special characters, hell I didn't even include numbers so far (yes I'm lazy). But you can add any character you want quite easily. I hope my event comments are satisfactory.

If you have a better solution please let me know. I'd really like to see this being improved. I already thought that I probably should have used a single sprite with different animations or frames for all the characters, but right now I'm happy it works at all (also regarding the fact that at first I had no clue how to do this).
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat Nov 15, 2008 3:20 am

That's a pretty cool example. :) I managed to remove 25 events(almost all of the letters) to make it more efficient and easier to sort through. All I had to do was replace all of those with one "Create object by name". It makes it a whole lot more efficient. There were a couple other changes to make this work right, so here's the modified CAP: Modified text display engine.

Also, just to keep in mind, obviously special characters can't be created like this since you can't name some of them properly.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Sat Nov 15, 2008 3:27 am

Very nice. I must have been blindfolded, never even noticed the "create object by name" action before. Embarrassing :oops:
But I noticed already there was a little problem with the space between characters ("o" not displayed correctly when trying "hello world!"). Will have a closer look at this.

But many many thanks for pointing this out! 8)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat Nov 15, 2008 4:36 am

Okay, fixed it. Now it should work properly. There was a problem with the use of the family "friendly" to get the width. Now it's checking if the DrawHere Object is overlapping friendly, so the width will be set correctly.

EDIT: Oh no now line breaks mess it up for some reason. Too bad. Needs a little work still. :(

EDIT2: Fixed now too, DrawHere was simply too big and therefore overlaping the characters in the line above as well after a line break. My bad.
It really really should work now hehe.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat Nov 15, 2008 5:22 am

that attachment doesn't work?
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Sat Nov 15, 2008 9:38 am

I just downloaded the attachment myself and tried it out. Worked fine. What exactly doesn't work for you?

EDIT: I noticed a minor glitch and did a slight update with some other small changes.

EDIT2: Was still glitchy, should be done now finally. :?
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat Nov 15, 2008 6:05 pm

This is pretty slick.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Nov 15, 2008 7:49 pm

Nice engine!

How about using a single sprite holding all letters in an animation? You could have a zero-speed animation so it doesn't change frame, and use frames 1-26 as letters, etc. Then you only need one object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 2 guests

cron