How do I use special characters with Sprite Fonts?

0 favourites
  • 9 posts
From the Asset Store
A collection of various soldier character sprites for creating a 2D platformer or sidescroller game
  • Hi,

    I am working in the key binding menu and I use a custom sprite font to display the actual bound keys. My question is:

    Is there a way to put keys like 'left arrow', 'right arrow', 'space bar' etc in the character set?

  • SpriteFont just maps keys to a grid position in the PNG file. Just add some extra characters that you won't use and edit those characters in the PNG to change the graphic to something else (left-arrow...). Since you are mapping keyboard-keys, presumably you are mapping capital letters, so you could use lowercase letters to map to your special keys.

  • SpriteFont just maps keys to a grid position in the PNG file. Just add some extra characters that you won't use and edit those characters in the PNG to change the graphic to something else (left-arrow...). Since you are mapping keyboard-keys, presumably you are mapping capital letters, so you could use lowercase letters to map to your special keys.

    But to display the letter I use 'Keyboard.StringFromKeyCode(key)', and they keycode of the bound key will not correspond with the 'Left arrow', for example. Am I right?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't realize the arrow keys do actually have characters,←→↑↓, so there is no problem there. See what string comes back from each key and use that, as long as it is only a single character.

  • font

    seem to work

  • korbaach blackhornet Nice, but how did you write that characters? Maybe a stupid question, but I don't know how u did it.

    And also I need 'Ctrl', 'Alt', Shift...

    Thanks, and sorry for too many questions

  • I just logged the text to the console and copied it. I don't know how to generate the actual characters from the keyboard. For control, alt, etc., they return strings, not characters, so you are going to have to search for those strings first, and convert to some special character that can be mapped in SpriteFont. 'Shift' is not reported as a key code.

  • I just logged the text to the console and copied it. I don't know how to generate the actual characters from the keyboard. For control, alt, etc., they return strings, not characters, so you are going to have to search for those strings first, and convert to some special character that can be mapped in SpriteFont. 'Shift' is not reported as a key code.

    Ok mate, thank you very much!

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