Critical bug with updating newText and graphicsCompatibility

Hi,

We’re in the middle of a crossroads and have no clue what to do before uploading our app to the App Store now that it’s opening again. We have to finally update our Corona build to the latest .2113 one, but doing so we have to now adapt to the new graphics engine which is causing us some bugs when using graphicsCompatibility v1.

The problem we’re having is that whenever we have a newText and update its text using the .text property, if the newText original label was for example ‘’, and we update it to something longer, say ‘Online’, we can not reset its reference point to fit the new width.

For example

local t = display.newText('', 0, 0, native.systemFont, 12) t:setReferencePoint(display.CenterLeftReferencePoint) t.x = 100; t.y = 100; t.origX = t.x; t.origY = t.y; local function delay() t.text = 'Online' t:setReferencePoint(display.CenterLeftReferencePoint) t.x = t.origX; t.y = t.origY; end timer.performWithDelay(100, delay)

In the example above, after setting the label of the text to ‘Online’ it is not possible to change the reference of the object to fit its new width and so we can not reposition the object accordingly.

Is there any workaround to solve this asap or is it just us doing something wrong? Would appreciate all help.

It looks like you’ve found a bug.

The only way I was able to get it to work was to replace the object when you want to update it.

local function delay()     local tx, ty = t.origX, t.origY;     t:removeSelf();     t = display.newText("Online", 0, 0, native.systemFont, 12)     t.origX, t.origY = tx, ty;     t:setReferencePoint(display.CenterLeftReferencePoint)     t.x = t.origX; t.y = t.origY; end

Maybe that can be an acceptable workaround at the moment?

Hey Ingemar, that’s what I feared. Sounds like your solution would work though, thanks.

Would be great if there was a global fix for this as it will require tons of rewrites.

For the record, if you use Graphics 2.0’s anchorX=0 it will work as expected.

But that will require that you remove your setReferencePoint statements.

Doesn’t seem to work when using the v1 compatibility, assume we’d have to move over to using the v2 code altogether and have to convert everything bit for bit

@ingemar thanks… that was also helpful for me

To get rid of the bug completely simply do obj.width=obj.width after updating the text and before repositioning it. For some reason that fixes it. //

thanks for ur advice !!

It looks like you’ve found a bug.

The only way I was able to get it to work was to replace the object when you want to update it.

local function delay()     local tx, ty = t.origX, t.origY;     t:removeSelf();     t = display.newText("Online", 0, 0, native.systemFont, 12)     t.origX, t.origY = tx, ty;     t:setReferencePoint(display.CenterLeftReferencePoint)     t.x = t.origX; t.y = t.origY; end

Maybe that can be an acceptable workaround at the moment?

Hey Ingemar, that’s what I feared. Sounds like your solution would work though, thanks.

Would be great if there was a global fix for this as it will require tons of rewrites.

For the record, if you use Graphics 2.0’s anchorX=0 it will work as expected.

But that will require that you remove your setReferencePoint statements.

Doesn’t seem to work when using the v1 compatibility, assume we’d have to move over to using the v2 code altogether and have to convert everything bit for bit

@ingemar thanks… that was also helpful for me

To get rid of the bug completely simply do obj.width=obj.width after updating the text and before repositioning it. For some reason that fixes it. //

thanks for ur advice !!