Would it be possible to support having an outline of the letters in a textfield?
Often the text may be on different backgrounds and it may be hard to see it, an outline solves this to some extent - and looks nice.
Tried to do it myself by adding another slightly larger textfield behind, but seems it needs to be done with double textfields for each letter, otherwise the outline will be off except for the center letter. Unless I'm doing something wrong.
Comments
Instead, I would create a outlined bitmap font with http://www.angelcode.com/products/bmfont/ (free, windows) or http://glyphdesigner.71squared.com/ (commercial, mac os) and then display each character with TextureRegion http://www.giderosmobile.com/documentation/reference_manual_2011.9.html#TextureRegion
On the other hand, this requires loading the parameters of character glyphs from a text file.
I've created a minimalist example of using BMFonts inside Gideros: http://github.com/gideros/BMFont/
Currently, it doesn't support kerning and unicode characters but I'm planning to add these features too.
I'm probably going to use this, thanks!
Btw, you have the name of the text file hardcoded in BMFont:init(), should be:
file = io.open(fontfile, "rt")
Thanks
Here I think best way is to handle automatic image resolution by yourself. I'm attaching a sample code. Here are the steps I've done:
1. I've created two fonts with sizes 100 and 50 and named them as font-hi and font-lo.
2. In main.lua I get the logical scale and test if it's greater than 1.5.
a. If yes, I'm loading font-hi and scale the BMTextField with inverse of logical scale.
b. If no, I'm loading font-lo and don't scale the BMTextField.
I've another solution but it's a little bit complicated because it requires modifying the file that contains the font glyph data. If this method doesn't suit you, I can also describe the other method.
Hope this helps,
cheers,
Supporting BMFonts natively (so that automatic image resolution works) is in the roadmap.
Good post, thanks.
Can you (or anyone) please explain what the:
text:setScale(scalex, scaley)
part does please?
1. Create a new project
2. Add an image to the project, let's say it's called image.png
3. now add a blank file called main.lua
4. now type the following code
Now add another line in the code towards the end
then try
In the sample above where you asked the question, text is an object that refers to the textField where as in this sample we are using _bmp which is an object of type bitmap/sprite. The fundamentals are the same, hope this helped you get an understanding of what setScale does.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps