How do I make sprite font character width to work correclty

Get help using Construct 2

Post » Fri Sep 25, 2015 10:52 am

Hi,

I'm experimenting with sprite fonts and I have something weird happening.
As explained in this tutorial, I put the character width actions in a "on start of layout" event.

During my layout, I create 2 times the same sprite font object, with the exact same text. the first time it is displayed correctly, the second time, the character width actions are ignored. Even if I copy all the character width actions after the object creation, it is still ignored.

As suggested in the tutorial, I put all my character width actions in a separate event sheet, and included it in an "on start of layout" event. I noticed that if I put the include in an "on start of layout" event, it is ignored even the first time, while if I put it simply on the top of the event sheet (even above the variables), the first time it's ok, then again it is ignored the second time the text is displayed.

Any idea of what's happening?
B
32
S
6
G
1
Posts: 352
Reputation: 2,812

Post » Fri Sep 25, 2015 10:10 pm

A) have you included the second event sheet in the first one?
B) can you post a simple example CAPX, so we can have a look?
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Sep 29, 2015 1:01 pm

@blackhornet
Thanks for the reply!
Actually I was able to make the sprite sheet's character width being normal by applying the character width action every tick. I also tried to create a function with the include, and call the function every time text is created, but the character width is not applied.

A simple question : does setting the character width at the start of layout set it correctly for the entire layout?
If yes, I probably have a problem in my event sheet, though I checked it many times and am not modifying character width anywhere.

To reply your questions :
A) I sure did.
B) Not at the moment because this is a project for my employer, so I will need to create a simple example using a different font (the sprite font I use is copyrighted by my company). But if your reply to my question above is affirmative and I am unable to make it work even in another simpler project, I will upload it for sure.

Thanks again!
B
32
S
6
G
1
Posts: 352
Reputation: 2,812

Post » Tue Sep 29, 2015 1:27 pm

Rable wrote:A simple question : does setting the character width at the start of layout set it correctly for the entire layout?

..lets say you have sprite w=64 ;h=64..you set on start of layout sprite width to 100..
then you create a new instance of same sprite...
Image

guess the width of the new instance...

i think you need to set character width(call function"set characters")
every time when you create new sprite font instance...
B
66
S
24
G
7
Posts: 1,515
Reputation: 11,041

Post » Tue Sep 29, 2015 2:24 pm

If you look at my Sprite Font generator thread, my example actually uses "On created", rather than "On start of layout". That will catch all creations.

sprite-font-generator-v2_t86546
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Wed Sep 30, 2015 12:42 pm

I spotted the problem : instead of applying the character width to the font family, as suggested in the forementionned tutorial, I changed the code and applied it to the font itself. This makes "on created" to work just fine!

"On start of layout" still doesn't work though.

Thanks a lot for your help in solving this problem!
B
32
S
6
G
1
Posts: 352
Reputation: 2,812


Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 36 guests