How do I make sprite font character width to work correclty

0 favourites
  • 6 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • 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?

  • 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?

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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...

    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...

  • 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.

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)