x/yReference / x/yOrigin can't be directly replaced by anchorX/Y for Graphics 2.0. Please bring back!

Hi guys,

I have been having all sorts of problems since migrating to Graphics 2.0!  I had code that I used as part of a couple of transitions to move my parallax scrolling background whilst dispatching events on it’s progress.  This was working really well before I migrated (it is based off the Atmosfall example in the Corona SDK Hotshot book).  I read in the blogs that anchorX/Y are substitutes for x/yOrigin and x/yReference.

I don’t know what I was thinking when I assumed that this would still “magically” work out of the box as all the above functions result in different values anyways - and I knew this prior!  Is there any way that these functions could be re-introduced?  I could (and am currently) running in v1 compatibility mode but then at some point I will be addressing this issue again and I would rather future-proof my code now.

Also, why were these removed?  It has broken the API contract.

Cheers,

Rich

There are a few problems with setReferencePoint and xReference and yReference that caused problems with Graphics 1.0. The main issue was around scaling and changing object sizes when reference points are changed. This is because the reference points used the object width and height values to compute the reference values. Based on the number of bug reports we received, this was causing problems for lots of users and introduced bugs that couldn’t be fixed with the current implementation.

When we designed Graphics 2.0, we replaced the x/yReference values with anchor points, which ranged from 0 to 1. Anchor point values are independent of the object actual width/height values and go a long way to eliminate the issues we had with the Graphics 1.0 implementation.

When you run in v1 compatibility mode l Graphics 2.0, setReferencePoint uses anchor points under the hood and x/yReferenece values are not implemented. In v1 mode, anchor points are not available in the API because they are not compatible with the Graphics 1.0 API. We found most users never used x/yReference since they were never intended to be manipulated directly (they are set internally by the setReferencePoint method).

When we say setReferencePoint (x/yReference) can be replaced by anchorX and anchorY, we are talking about Graphics 2 in non-v1 compatibility mode. If you run your code in v1 mode, you are restricted to using the setReferencePoint method to change objects reference points to the standard offsets (TopLeft, TopRight, Center, etc.).

If you convert your program to run in Graphics 2.0 mode, you could use anchorX and anchorY to emulate what you did with xReference and yReference. For your existing code, you might look at your code implementation to see if you can do the same things by manipulating x,y values.

The v1 compatibility mode was introduced to help users transition to Graphics 2 without having to make many changes to their existing program. For all new projects we recommend moving to the full Graphics 2 API. All new features added to Graphics 2.0 won’t be available in v1 mode so we see the v1 mode only being used for a limited time.

Tom

Hey Tom,

Thanks for justifying why these changes were made.  I didn’t realise that there were so many issues caused by existing setRefPoint/x/yRef functionality.  I will have to just try to transition all this functionality across as best I can or just try to come up with a different solution for this.  If I have any problems with the transition to anchorX/Y can I post in here? Or create new post?

Cheers,

Rich

You can emulate the x/yReference with this sort of thing:

[lua]

thingamabob.anchorX = xReferenceYouWantToSet / thingamabob.width

thingamabob.anchorY = yReferenceYouWantToSet / thingamabob.height

[/lua]

  • C

Setting the anchor point only works in true Graphics 2.0 mode. It won’t work if the v1 Compatibility mode.

There are a few problems with setReferencePoint and xReference and yReference that caused problems with Graphics 1.0. The main issue was around scaling and changing object sizes when reference points are changed. This is because the reference points used the object width and height values to compute the reference values. Based on the number of bug reports we received, this was causing problems for lots of users and introduced bugs that couldn’t be fixed with the current implementation.

When we designed Graphics 2.0, we replaced the x/yReference values with anchor points, which ranged from 0 to 1. Anchor point values are independent of the object actual width/height values and go a long way to eliminate the issues we had with the Graphics 1.0 implementation.

When you run in v1 compatibility mode l Graphics 2.0, setReferencePoint uses anchor points under the hood and x/yReferenece values are not implemented. In v1 mode, anchor points are not available in the API because they are not compatible with the Graphics 1.0 API. We found most users never used x/yReference since they were never intended to be manipulated directly (they are set internally by the setReferencePoint method).

When we say setReferencePoint (x/yReference) can be replaced by anchorX and anchorY, we are talking about Graphics 2 in non-v1 compatibility mode. If you run your code in v1 mode, you are restricted to using the setReferencePoint method to change objects reference points to the standard offsets (TopLeft, TopRight, Center, etc.).

If you convert your program to run in Graphics 2.0 mode, you could use anchorX and anchorY to emulate what you did with xReference and yReference. For your existing code, you might look at your code implementation to see if you can do the same things by manipulating x,y values.

The v1 compatibility mode was introduced to help users transition to Graphics 2 without having to make many changes to their existing program. For all new projects we recommend moving to the full Graphics 2 API. All new features added to Graphics 2.0 won’t be available in v1 mode so we see the v1 mode only being used for a limited time.

Tom

Hey Tom,

Thanks for justifying why these changes were made.  I didn’t realise that there were so many issues caused by existing setRefPoint/x/yRef functionality.  I will have to just try to transition all this functionality across as best I can or just try to come up with a different solution for this.  If I have any problems with the transition to anchorX/Y can I post in here? Or create new post?

Cheers,

Rich

You can emulate the x/yReference with this sort of thing:

[lua]

thingamabob.anchorX = xReferenceYouWantToSet / thingamabob.width

thingamabob.anchorY = yReferenceYouWantToSet / thingamabob.height

[/lua]

  • C

Setting the anchor point only works in true Graphics 2.0 mode. It won’t work if the v1 Compatibility mode.

and what about negative values? guess that wont work??

Unfortunately, nope.

  • Caleb

so basically, if you have an app with - yReference, you are screwed when trying to migrate to 2.0.

nice. not.

and what about negative values? guess that wont work??

Unfortunately, nope.

  • Caleb

so basically, if you have an app with - yReference, you are screwed when trying to migrate to 2.0.

nice. not.