Need help setting a SpriteFont text.

Get help using Construct 2

Post » Thu Feb 20, 2014 2:02 am

Hey all, I tried searching for this topic in the forums, so I apologize if I missed it, but I've run into some trouble, and I'm hoping someone can throw me an answer.

I'm trying to create a character screen for a player that reflects its stats.

I have a dictionary called "PlayerAttributes" with an instance variable called "Strength" and I created a SpriteFont which I want to display the current Strength value. What I tried doing was putting in:

Every tick - set SpriteFont text : PlayerAttributes.Strength

in my event sheet, but it doesn't work. Is it possible to set a textbox, or spritefont's text to a numerical instance variable, or does it have to be a string?

Hope my question is understandable. Please help!

Thanks.
-BabyCave
B
9
S
2
Posts: 37
Reputation: 739

Post » Thu Feb 20, 2014 2:33 am

That should be fine. Is your object big enough to show the full value?

Does your character set show all characters?
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,852

Post » Thu Feb 20, 2014 5:10 am

Hurr durr.

I just realized I didn't have the layout assigned to the correct event sheet.

Thanks for telling me the event should be okay!!
B
9
S
2
Posts: 37
Reputation: 739

Post » Thu Feb 20, 2014 11:19 am

Hi baby
Consider using Sprite font+ Plugin.If you are using sprite fonts often,You may find it difficult that during runtime and editing time, fonts are rendered differently if you assign custom character widths in the event sheet.
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Fri Feb 21, 2014 8:49 pm

Hey Doc,

I'll definitely look into that. Thanks!
B
9
S
2
Posts: 37
Reputation: 739

Post » Thu May 01, 2014 3:59 pm

@Blackhornet,

I just noticed your comment about not all the characters in the set showing. I am trying to create a completely custom character set, but only about half of them show at runtime. Is this because the widths are set incorrectly?

I am using GiveYourFontsMono, and all characters are showing there, but some are missing at runtime.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
47
S
13
G
20
Posts: 371
Reputation: 14,445

Post » Thu May 01, 2014 4:01 pm

Have you copied the set exactly from my app to C2, and implemented the width code from the sample with the data in the TXT file generated with the image?
ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,852

Post » Thu May 01, 2014 5:20 pm

I stole your sample and added a bunch of new characters as shown below:
spritefont.PNG


When I run the .capx above, some of the characters don't show up at all. My initial thought was that Spritefont can only handle characters in a very limited character set. For example, θ (Θ) shows up just fine within the text plugin, but not at all as a spritefont.
You do not have the required permissions to view the files attached to this post.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
47
S
13
G
20
Posts: 371
Reputation: 14,445

Post » Thu May 01, 2014 5:45 pm

spritefontdisplay.PNG


This is what is displaying. Note the lack of the θ character in the spritefont, and the big gap between the capital "I" and the capital "J".
You do not have the required permissions to view the files attached to this post.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
47
S
13
G
20
Posts: 371
Reputation: 14,445

Post » Thu May 01, 2014 6:28 pm

Can you post the CAPX?
ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,852

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests