Tab Bars/ListViews w/ retina text

I’m working on an app that uses a tab bar,list views, and storyboard (love it!) throughout and being that I’m nearly done with the logic I started on the polishing and wanted to add retina text, but I ran into an issue. What I had was the content in the config file set to 320x480 so I could use “points” instead of pixels to layout the interface, which has worked wonderfully until I started in on retina text. Because the size of the text changes I was going to use a scalefactor to determine the location in the interface. In other words, I would check for the resolution to be 320 and handle the alignment one way, but if it was 640 then handle it for the newer iPhones.

That’s when I figured out that by setting the content size in the config file to 320x480 made it so that display.contentWidth always returns whatever is in the config file.

The easiest solution I could see for being able to set the content size in the config file AND be able to use a scalefactor for retina and non-retina displays is to have a display.resolutionWidth that gets the actual resolution of the display instead of what it was set to in the config file.

Having something like this would allow me to align text properly depending on the resolution as well as scaling images down for the 3GS and leaving them full size for retina displays.

One thought I had was to somehow check the resolution in the config file and save that to a variable or a database BEFORE I set the content size, but I don’t know if that’s even possible.

So a few questions: I think everyone agree that it would be wonderful if display.newText just took care of retina text automatically so we don’t even have to think about it. Is this possible in the near future?

If not, does a feature exist that allows me to check actual resolution, not just the content size? Or is there a way to check content size in the config before setting it? If anyone has a way around this or any advice I’d greatly appreciate it. Thanks in advance. [import]uid: 39480 topic_id: 18705 reply_id: 318705[/import]

You can use newRetinaText(), that takes care of the retina resolution for you :slight_smile: [import]uid: 14018 topic_id: 18705 reply_id: 71885[/import]

Using newRetinaText() is what I was using that started causing the alignment problems. It’s what I was trying to fix by setting the alignment one way if it was retina and setting it another for non-retina. Thanks for your reply though. [import]uid: 39480 topic_id: 18705 reply_id: 71887[/import]

Anyone have a solution or advice they can offer on my above post? Thank you. [import]uid: 39480 topic_id: 18705 reply_id: 73273[/import]

I think I saw in the release notes that display.newRetinaText is now CenterReferencePoint like display.newText instead of TopLeftReferencePoint.

Maybe I was dreaming. [import]uid: 19626 topic_id: 18705 reply_id: 73278[/import]

So I discovered a really round about way to find out if I’m on a retina screen or not even with the content size set in the config.lua. Here’s the code I put in my main.lua file so I can access theMultiplier from anywhere:

retinaTestText = display.newRetinaText("Text", 0, 0, native.systemFont, 10)  
retinaTestText:setTextColor(0, 0, 0, 0)  
  
theMultiplier = 1  
  
if(retinaTestText.width == 24)  
 then  
 theMultiplier = 1  
else  
 theMultiplier = .5  
end  
  
retinaTestText:removeSelf()  

Using theMultiplier I am able to set the alignment of text based on if it’s a retina screen or not. This feels like a hack and a half, but it works for now.

My new question is this. How does display.newRetinaText know it’s a retina screen? If I could do the same thing to find out the content size then I wouldn’t have to do this hack. Thanks in advance for any help that can be offerred. [import]uid: 39480 topic_id: 18705 reply_id: 73808[/import]

Regarding retina text:

display.newText() has been modified to handle “retina text” automatically, and therefore display.newRetinaText() has been deprecated since it is no longer needed.

The changes will be reflected in the next daily build (the one posted *after* 2012.770).
[import]uid: 52430 topic_id: 18705 reply_id: 94928[/import]