If you're putting your text field exactly at (some integer + 0.5) and the underlying OpenGL implementation has some precision problems (like Xcode simulator) you can get such problems.
Some solutions are: 1. adding/subtracting a small amount (e.g. 0.01) to/from your coordinates 2. using math.floor 3. ignoring the problem (hopefully it'll be displayed ok on real device)
btw, what is your font?
edit: for example open Fonts example, change all x-coordinates from 10 to 10.5 and test it on both real device and Xcode simulator.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@Atilim On the new version I'm trying to run via eclipse (as the apk's wouldn't run!) and I get errors to do with bad characters when it's parsing the lua files (so the program doesn't run). is this to do with the encrypted lua files? Do I have to do anything to enable the decryption? The program works through the player.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@OZApps if you have a paid license, compiled Lua bytecodes are encrypted. If you have a free license, they aren't.
@alexzheng Each of TFont.new("test.ttf", 12, "123") will create different textures. And new Core.class is included (only postInit). Let me update the release notes.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
I still suspect from an old library or a file stored at cache. Can you do these steps:
1. In Eclipse, right click on the project and select "Delete". Also select "Delete project contents on disk (cannot be undone)" 2. If there are still some files in the export directory, delete them also. 3. Export from Gideros Studio, import from Eclipse, run.
If still no success, can you send me the exported project? (atilim@giderosm....com)
I had to completely delete the project from the eclipse area, reexport it, reimport into eclipse, etc... It worked after doing this.
Any ideas on how not to have to do this for every project?
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
That's what I'm having - if you fully delete and reexport/reimport then it works.
@atilim - looks like it's happening with my other projects too. Just tried bacteria and same problem reading a lua file.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@atilim I've been though all the files in the project dir and comparing a working version with a non-working version and they seem the same. Because the lua file seems corrupt I'm guessing it must be something to do with encryption?
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@SinisterSoft I also think it's all about encryption.It seems there is a mismatch between encrypted Lua files and libgideros.so because of Eclipse caching.
When you export a project, a new 128-bit key is generated and Lua files are encrypted with it. Therefore you see different Lua files for each export. I think I should generate the key once and reuse it with each export.
Playing around with the Font classes, I hit a little problem. I'm currently trying to extend TextFields so that the text is right-aligned. So I thought that the following code should work:
myTextField:setPosition( x - myTextField:getWidth(), y )
But it seems that the function 'TextField:getWidth()' doesn't take into account the 'xoffset' of the font metrics, so the text field might be off by a few pixels. I tested this with a large bitmap font (created from Arial Black with size 48) when the difference in alignment can be several pixels. Is there a way around this?
I have attached a full project which demonstrates the problem.
Comments
I this still have a problem with TextField and TTFont rendering in this version
Any idea what may be the source of problem vidible on the image below?
Thanks
If you're putting your text field exactly at (some integer + 0.5) and the underlying OpenGL implementation has some precision problems (like Xcode simulator) you can get such problems.
Some solutions are:
1. adding/subtracting a small amount (e.g. 0.01) to/from your coordinates
2. using math.floor
3. ignoring the problem (hopefully it'll be displayed ok on real device)
btw, what is your font?
edit: for example open Fonts example, change all x-coordinates from 10 to 10.5 and test it on both real device and Xcode simulator.
I have this problem on real android device. I try to use the rounding for list scrolling and we'll see
Problem was in this line (centering):
text:setPosition((w-text:getWidth())/2, (h+text:getHeight())/2)
This correction fixed my problem:
text:setPosition(math.floor((w-text:getWidth())/2), math.floor((h+text:getHeight())/2))
The ultimate doc still missing some description about font metric like kerning etc, hopefully it will be added soon
http://www.nightspade.com
It is nice that basic functionality is not crippled in the paid vs Free licenses.
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
If I call local font = TTFont.new(test.ttf, 12, '123') in dfferenct places, will all these font reference the same cache?
https://sites.google.com/site/xraystudiogame
https://sites.google.com/site/xraystudiogame
Thanks for all the hard work.
https://deluxepixel.com
Likes: bml
Ultimate Games on Appstore
Ultimate Games on Google Play
www.tntengine.com
https://deluxepixel.com
@alexzheng Each of TFont.new("test.ttf", 12, "123") will create different textures. And new Core.class is included (only postInit). Let me update the release notes.
@SinisterSoft Can you do a fresh export?
Likes: OZApps
https://deluxepixel.com
1. In Eclipse, right click on the project and select "Delete". Also select "Delete project contents on disk (cannot be undone)"
2. If there are still some files in the export directory, delete them also.
3. Export from Gideros Studio, import from Eclipse, run.
If still no success, can you send me the exported project? (atilim@giderosm....com)
Any ideas on how not to have to do this for every project?
https://deluxepixel.com
https://deluxepixel.com
@atilim - looks like it's happening with my other projects too. Just tried bacteria and same problem reading a lua file.
https://deluxepixel.com
@unlying is your game working on android player? If so, do the steps http://giderosmobile.com/forum/discussion/comment/19607#Comment_19607
https://deluxepixel.com
When you export a project, a new 128-bit key is generated and Lua files are encrypted with it. Therefore you see different Lua files for each export. I think I should generate the key once and reuse it with each export.
Playing around with the Font classes, I hit a little problem. I'm currently trying to extend TextFields so that the text is right-aligned. So I thought that the following code should work:
myTextField:setPosition( x - myTextField:getWidth(), y )
But it seems that the function 'TextField:getWidth()' doesn't take into account the 'xoffset' of the font metrics, so the text field might be off by a few pixels. I tested this with a large bitmap font (created from Arial Black with size 48) when the difference in alignment can be several pixels. Is there a way around this?
I have attached a full project which demonstrates the problem.
Likes: MobAmuse