\t does not work

Hey

I’ve created a text object and want it to display the current and next level.
I would like to have a tab between the text and the level number so it displays like this:

Current level: 10
Next level: 11

… and I’ve tried to make a string like this:
“Current level:\t10\nNext level:\t11”

…but it doesn’t display the tab, there is no space in between

Anyone with any tips?

[import]uid: 95786 topic_id: 21383 reply_id: 321383[/import]

I don’t think we currently have support for \t, however I’m not 100% sure on that so will try to track down an answer for you. [import]uid: 52491 topic_id: 21383 reply_id: 84739[/import]

To use \n and \t you need to give the text newText a width and height

display.newText( [parentGroup,] string, left, top,  
 [width, height,] font, size )  

an example of this that fits your situation would be something like this…

local myText = display.newText("Current level:\t10\nNext level:\t11", 0, 0, 200, 100, native.systemFont, 16)  

(with 200 being the width and 100 being the height)

Using just one \t doesn’t look like its doing much but it is doing the tab (try \t\t and you will notice it then). [import]uid: 69700 topic_id: 21383 reply_id: 84745[/import]

Hmmm… Still can’t get it working properly, even if I set the scale [import]uid: 95786 topic_id: 21383 reply_id: 84755[/import]

Hey, thanks Ertzel! I don’t know why I was under the impression we had issues with it but you’re right :slight_smile: Excellent!

@pfeiring - Ertzel’s code with one extra \t added shows very clearly \t working - try running just this code;
[lua]local myText = display.newText(“Current level:\t\t10\nNext level:\t11”, 0, 0, 200, 100, native.systemFont, 16)[/lua]

(That’s with the extra \t.)

Peach :slight_smile: [import]uid: 52491 topic_id: 21383 reply_id: 84879[/import]