Problem when changing Anchor Points in Sprites

Hi!

I’m currently having a problem to play sprite animations when the sprite has its anchorX and anchorY attrs changed from the default values (0.5 and 0.5). Animations behave in a strange way, the frames seem to jump and the end result is really bad. I’m currently changing the anchor points to (0.2 and 0.8). If I reset them to the center (0.5, 0.5), animations get smooth again.

The problem is well described here: https://forums.coronalabs.com/topic/50025-stuttering-sprites-in-graphics-20/?hl=%252Bimage+%252Bsheet+%252Banchor#entry259436

This post is from 2014 and I can confirm it’s still happening.

Br,

Cleverson

attaching_files.jpgCan you make a small demo project for us to look at and run, in order to see the problem and help you?
 
You can attach it as a zip file here.
 

Hi Ed!

Thanks for your reply. I’ve tried to use that Corona horse sample changing its anchor points but without success. In this sample, everything works fine even when anchor points are changed.

So, I think the problem may be in how my game sprite sheet is exported by TexturePacker. I changed the Horse Sample to include my sprite sheet instead of the horse and I could reproduce the problem. I’m attaching the files I changed in the Horse Sample, just replace them and run the game to see what’s happening. In order to see the expected behaviour, just comment the following lines in main.lua

display.setDefault( "anchorX", 0.0 ) display.setDefault( "anchorY", 0.0 )

Br,

Cleverson

Hi.  There was a longer post here, but I feared it would be taken wrongly so I purged it.

Long story short, I really wanted a ready-to-run example and definitely didn’t want to poke around the example that comes with Corona.  

So I put together my own example below.  See following post.

  • Cheers

** UPDATE ** This does look a bit like a bug to me, BUT I feel like I’m missing something here and I wonder if this can’t be resolved using additional sprite settings or details.  I’m posting the code here for you and for others who might have insights.

https://www.youtube.com/watch?v=_mZrDhC04rQ&feature=youtu.be

Video shows ex1, ** ex2 contains your sprites, but no code**

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/03/spriteAnchors.zip

Note: the last example has the dot in the wrong place.  It needs to be offset by the opposite values I have in the code. (Pretty sure on this)

attaching_files.jpgCan you make a small demo project for us to look at and run, in order to see the problem and help you?
 
You can attach it as a zip file here.
 

Hi Ed!

Thanks for your reply. I’ve tried to use that Corona horse sample changing its anchor points but without success. In this sample, everything works fine even when anchor points are changed.

So, I think the problem may be in how my game sprite sheet is exported by TexturePacker. I changed the Horse Sample to include my sprite sheet instead of the horse and I could reproduce the problem. I’m attaching the files I changed in the Horse Sample, just replace them and run the game to see what’s happening. In order to see the expected behaviour, just comment the following lines in main.lua

display.setDefault( "anchorX", 0.0 ) display.setDefault( "anchorY", 0.0 )

Br,

Cleverson

Hi.  There was a longer post here, but I feared it would be taken wrongly so I purged it.

Long story short, I really wanted a ready-to-run example and definitely didn’t want to poke around the example that comes with Corona.  

So I put together my own example below.  See following post.

  • Cheers

** UPDATE ** This does look a bit like a bug to me, BUT I feel like I’m missing something here and I wonder if this can’t be resolved using additional sprite settings or details.  I’m posting the code here for you and for others who might have insights.

https://www.youtube.com/watch?v=_mZrDhC04rQ&feature=youtu.be

Video shows ex1, ** ex2 contains your sprites, but no code**

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/03/spriteAnchors.zip

Note: the last example has the dot in the wrong place.  It needs to be offset by the opposite values I have in the code. (Pretty sure on this)