[Request] Spritefont colors (extra characters)

Discussion and feedback on Construct 2

Post » Sun Oct 30, 2016 4:32 pm

Hi there @ashley @tom

I've been looking for ways to add extra colors to my spritefont. I've looked through the js code for the spritefont object and it seems that the first thing it does is to take the characters listed in the object properties and split the spritefont sprite sheet so it assigns each letter to a piece of the sprite sheet.

The problem with this is that it makes it impossible to have extra characters in the spritefont sprite sheet without having a character assigned to it to be used later.

Here's a spritefont image for instance:
Image
(please don't mind the cropping or badly colored letters, it's just an example)

I'd like to be able to do something like:
Start of level -> set spritefont text to "test" -> change Y offset to +400 -> append spritefont text "test2"
So the "test" part would be white and the "test2" part would be green.

I know this might be a bit too much to ask but would you kindly consider adding this to the spritefont object?

Thanks!
B
123
S
43
G
41
Posts: 846
Reputation: 28,204

Post » Mon Oct 31, 2016 3:40 am

Heh, I've been requesting this since the Construct Classic days. Ended up making my own bitmap font system with sprite objects: https://twitter.com/Tokinsom/status/774121334288683008

Ain't easy tho.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Mon Oct 31, 2016 11:06 am

The spritefont object is designed to represent a single font, and this basically comes down to two things: representing multiple fonts in the same object, and then effectively a rich-text engine to be able to display multiple font styles within the same text run.

Both are pretty complicated features to add, and I'm a bit sceptical of the design. For example I think it would be better to leave a spritefont as representing just one font, but then have a way to merge different spritefont objects in the same run of text. But then you still need some kind of markup and parser to specify where you want which font styles...
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,694

Post » Mon Oct 31, 2016 1:31 pm

@Tokinsom Very nice! I'd definitely buy it if you put it in the store.

@Ashley I've thought a lot about the last method you've mentioned but is there a way to know the position of the last character typed to append the next spritefont object?
B
123
S
43
G
41
Posts: 846
Reputation: 28,204

Post » Mon Oct 31, 2016 1:32 pm

Tokinsom wrote:Heh, I've been requesting this since the Construct Classic days. Ended up making my own bitmap font system with sprite objects: https://twitter.com/Tokinsom/status/774121334288683008

Ain't easy tho.


Looks really nice.
And you gave me a lot of ideas for my own implementation. So thanks. :D
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Mon Oct 31, 2016 3:08 pm

You might be able to achieve different font colors by using the "Set Color" effect.
It will not help you for the case of changing single chars though and that's what you're looking for I guess.
ImageImageImage
B
60
S
22
G
78
Posts: 646
Reputation: 44,730

Post » Mon Oct 31, 2016 5:38 pm

Has anyone ever thought about using a shader?
Not to color objects, but to map out a texture.
Image ImageImage
B
168
S
50
G
169
Posts: 8,283
Reputation: 108,195

Post » Mon Oct 31, 2016 8:20 pm

Tokinsom wrote:Heh, I've been requesting this since the Construct Classic days. Ended up making my own bitmap font system with sprite objects: https://twitter.com/Tokinsom/status/774121334288683008

Ain't easy tho.


Image
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,183

Post » Mon Oct 31, 2016 9:44 pm

@Andreyin @bilgekaan Ha, I'd like to get it on there but it's still missing some features like horizontal & vertical alignments and variable character width. These aren't completely necessary but I think it would be hard to sell without. I quit working on this a while back since it was enough for my current project but I'll try finishing it.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Mon Nov 07, 2016 1:07 pm

Ashley wrote:I think it would be better to leave a spritefont as representing just one font, but then have a way to merge different spritefont objects in the same run of text. But then you still need some kind of markup and parser to specify where you want which font styles...


@Ashley This would be perfect! Having a phrase like "You always do this to me!" could then be easily done by switching the spritefont to a bold italics version of the font for just the word "always", and then switching back to the regular version for the rest of the sentence. I really hope something like this gets implemented.

Tokinsom wrote:I quit working on this a while back since it was enough for my current project but I'll try finishing it.


@Tokinsom Please let me know when you release this. I've been trying to work with plugins and addons to create a text system as versatile this for a while now, and I've been coming up against a brick wall every time.

Can this system work with any spritefont, or only the specific one you're using?
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Next

Return to Construct 2 General

Who is online

Users browsing this forum: A2D, paxto22, Refeuh and 2 guests