HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.96k stars 431 forks source link

FlxText wishlist #1952

Open xerosugar opened 7 years ago

xerosugar commented 7 years ago

Please make it possible to set letter spacing on FlxText. It's important to be able to do this if you happen to be working with a bold font in order to increase readability.

Also, a way of adjusting the position of specific characters slightly in order to do that letter-wiggle effect you see in some games? Alternatively, a tutorial or snippet that demonstrates how to do this in the cheatsheet or something.

MSGhero commented 7 years ago

Someone managed to do the latter by (extending and overriding maybe? and) messing with the individual character matrices. However, that's only a thing in FlxBitmapText. FlxText iirc just shows the underlying OpenFL/Flash textfield, in which you can't jitter the letters.

JoeCreates commented 7 years ago

I implemented a way of doing this and various other text effects, such as zooming or moving letters in individually. Each character needs to be a separate sprite. See CinematicText in my Lycan repo.

MSGhero commented 7 years ago

Maybe this should not go into FlxText, but rather FlxFancyText or something. Then with #2066, the three are largely interchangeable. I doubt text wiggling is possible without completely rewriting FlxText's flash text Textfield implementation.

Gama11 commented 7 years ago

I think it would be fine if this was only supported by a third-party library, Flixel can't include everything. I've directed a few people to Lycan's CinematicText already.

@JoeCreates One question - how do you actually use it / is there a usage example somewhere? It seems to be intended as more of a base class, with showLetter() and hideLetter() not being implemented / throwing "Implement me".

JoeCreates commented 7 years ago

@Gama11 I originally made it for a Ludum Dare game, and the main purpose is to bring in and send off text in cool ways. One example usage is in Werewolf Tycoon here on the text "NIGHT 4": https://www.youtube.com/watch?v=xEvTDNl7eLY&t=176. The code for this is here: https://gist.github.com/JoeCreates/b3dc48a20a93dd1d69f8537d8dbf84f5

Like much of Lycan, I haven't put a great deal of effort into documenting or considering how other people might want to use it. :P It's been a while since I touched that class and I can think of many ways of improving it and making it more flexible. I plan on eventually putting a bunch of actual implementations into Lycan.

Jiggling text could be achieved by putting tweens on each character in showLetter that tween the offsets, and onComplete start a new tween. Alternatively, for a less smooth jiggling, just timers which randomly set the offsets then restart the timer.