Migrating from old sprite libraries

Hi,

We are having an issue migrating one of our client’s apps to the latest sprite api’s. I’m using your adapter library for the old api’s, which is working well. However, I’m experiencing a problem when some of the textures actually move around within the frames.

Your docs state here: http://docs.coronalabs.com/api/library/graphics/newImageSheet.html

"Image sheet packing tools such as Texture Packer will output the sourceX,

sourceY, sourceWidth, and sourceHeight parameters for trimmed frames.

When displaying these frames on the screen, the image will be positioned

in respect to the *center point* of the untrimmed frame size.”

I believe this is causing a lot of positioning issues for the sprite as a whole. The app depends on the reference point being the top left point, and I think that is of the untrimmed frame. My current solution is to use 0,0 as the anchor points and to listen for sprite events and calculate an offset every frame to help me keep the sprites’s current positioning.

Is there a simpler, or more effective way of doing this? I need to replicate the legacy behavior of a sprite when its frame is larger than the texture and is positioned by the top left reference point.

Thanks!

Secondarily, I found a small issue with this framework:

https://github.com/coronalabs/framework-sprite-legacy

It doesn’t allow a loopCount of anything other than 1, -1, or -2. I often have loop counts of 2. I patched my own version to support positive loop counts other than 1, but I haven’t had time to make a pull request.

I found another topic related to this:

http://forums.coronalabs.com/topic/43837-sprite-positioning-and-texturepackers-trim-function/

That helped me solve my problem. I’m now doing a couple of things:

  1. using 0.5, 0.5 as the sprite’s anchor points

  2. offsetting the sprite by half of the source/untrimmed frame size

  3. wrapping all of that in a group and using the same positioning I would have applied to the sprite using the old sprite library

I found another topic related to this:

http://forums.coronalabs.com/topic/43837-sprite-positioning-and-texturepackers-trim-function/

That helped me solve my problem. I’m now doing a couple of things:

  1. using 0.5, 0.5 as the sprite’s anchor points

  2. offsetting the sprite by half of the source/untrimmed frame size

  3. wrapping all of that in a group and using the same positioning I would have applied to the sprite using the old sprite library