Changes in code from Corona version to version

Hi All

I am reletively new to programming and I wrote some code about 6 months ago in version 2011.704 (2011.12.8), which worked perfectly. The PC fell apart so I had to get a new PC and re-install Corona, which ended up being version 2013.1137 (2013.6.7), but now the code doesn’t work the same way.

The actual code that didn’t work was centering the scene and objects.

I used the following:

    screenGroup.x = centerX
    screenGroup.y = centerY

in “function scene:createScene(event)”

and this centered everything in the earlier version, but in the new version it seems to ignor the code in this function and I have found in order to get the scene to center I had to move the code to function “function scene:enterScene(event)”.

Why has this happened?

Will I encounter more changes like this?

Is there a better way to center my scene?

Thank you

Regards

Ozan

Well I don’t know where your values for centerX and centerY are being defined.  Those are not standard Corona SDK variables.  

I would recommend using:  display.contentCenterX and display.contentCenterY for those values.

Now since it works in enterScene, they must be defined somewhere.   Is it entering up in the bottom right quarter of the screen?  If so, then there is a reference point change.

As far as the future goes, we try to avoid breaking changes, but there are times they can’t be helped.  Sometimes new features require changes.  Sometimes bug fixes required changes.

Thanks for the reply. I defined the values at the start before the functions:

local centerX = defaultWidth/2;
local centerY = defaultHeight/2;

and my code worked perfectly in Corona version 2011.704. I didn’t change the code but when I tried running it in Corona version 2013.1137 the bottom right corner of my scene was in the middle of the screen.

It works fine now that I moved the code to the other function but I was supprised when it was working a few months ago and needed changing this time to get it to work. I have decided to remove my code and replace it with your suggestion as it reduces my code by two lines:

screenGroup.x = display.contentCenterX
screenGroup.y = display.contentCenterY

Thanks for your help

Ozan

You might want to do add this line before you center the group:

screenGroup:setReferencePoint(display.CenterReferencePoint)

Well I don’t know where your values for centerX and centerY are being defined.  Those are not standard Corona SDK variables.  

I would recommend using:  display.contentCenterX and display.contentCenterY for those values.

Now since it works in enterScene, they must be defined somewhere.   Is it entering up in the bottom right quarter of the screen?  If so, then there is a reference point change.

As far as the future goes, we try to avoid breaking changes, but there are times they can’t be helped.  Sometimes new features require changes.  Sometimes bug fixes required changes.

Thanks for the reply. I defined the values at the start before the functions:

local centerX = defaultWidth/2;
local centerY = defaultHeight/2;

and my code worked perfectly in Corona version 2011.704. I didn’t change the code but when I tried running it in Corona version 2013.1137 the bottom right corner of my scene was in the middle of the screen.

It works fine now that I moved the code to the other function but I was supprised when it was working a few months ago and needed changing this time to get it to work. I have decided to remove my code and replace it with your suggestion as it reduces my code by two lines:

screenGroup.x = display.contentCenterX
screenGroup.y = display.contentCenterY

Thanks for your help

Ozan

You might want to do add this line before you center the group:

screenGroup:setReferencePoint(display.CenterReferencePoint)