No need to replace any of your code. Here’s a patched version of display.newText that is not only compatible with retina devices, but will NOT do anything on devices that aren’t retina-display capable (thus, preserving texture memory).
Just add the following code to the top of your main.lua file (before any calls to display.newText):
[blockcode]
local OldnewText = display.newText
display.newText = function( text, xPos, yPos, font, size )
local actualText = text or “”
local actualFont = font or “Helvetica”
local actualSize = size or 16
local xScale, yScale = display.contentScaleX, display.contentScaleY
local sizeMultiply = 1
if xScale < 1.0 or yScale < 1.0 then
sizeMultiply = 2
end
local t = OldnewText( actualText, 0, 0, actualFont, actualSize * sizeMultiply )
t:setReferencePoint( display.TopLeftReferencePoint )
t.xScale, t.yScale = xScale, yScale
t.x, t.y = xPos, yPos or 0, 0
return t
end
[/blockcode]
Using the function above, you shouldn’t have to rewrite any of your code (as long as you’re using display.newText to create text). It “just works” as a replacement to the old newText function.
The patched display.newText above completely replaces the need for the newRetinaText() function I mentioned at the start of this thread.
Btw: this patched function should behave exactly the same as the old newText() function (positioning should be the same across the board, etc.) so it shouldn’t break any code. [import]uid: 52430 topic_id: 4573 reply_id: 38284[/import]