How to obtain the sourceHeight and sourceWidth of the trimmed image?

As from the title, I create a spritesheet using Texture Packer, and I am accessing using:

local circle = display.newImage(sheet, data:getFrameIndex("circle"))  

When the circle has height and width of 100 x 100, while the circle.png is 200 x 200.

when I print circle.width, I got 100, but not 200.

How to solve this problem?

The extra transparent space that I created is actually for padding purpose, which I am intentionally place there.

Hi @topfuncoolgames,

I can’t remember exactly how TexturePacker builds its functions (i.e. the function that returns all the frames, and their info), but I think you can solve this by enhancing those functions and telling them to return more information from, for example, the following…

[lua]

{

        x = 2,

        y = 155,

        width = 219,

        height = 155,

        sourceX = 0,

        sourceY = 4,

        sourceWidth = 227,

        sourceHeight = 161,

    },

[/lua]

…and then you should be able to gather/use that information to calculate the “original” size of the pre-trimmed frame.

Brent

Hi @topfuncoolgames,

I can’t remember exactly how TexturePacker builds its functions (i.e. the function that returns all the frames, and their info), but I think you can solve this by enhancing those functions and telling them to return more information from, for example, the following…

[lua]

{

        x = 2,

        y = 155,

        width = 219,

        height = 155,

        sourceX = 0,

        sourceY = 4,

        sourceWidth = 227,

        sourceHeight = 161,

    },

[/lua]

…and then you should be able to gather/use that information to calculate the “original” size of the pre-trimmed frame.

Brent