width and height of imagesheet sprite gets reset when animation is played

So I am using Corona’s image sheet library. I found that if I create a sprite with animation and then change its width by setting its width property, when I start playing animations the width is reset. Am I missing something here?

--------------------CODE

local sequenceData = {}

sequenceData[1] =  {name=“default”, frames={ 10}, time=100,  loopCount=1}

sequenceData[2] = {name=“toggled”, frames={ 34}, time=1000, loopCount=1}

local l = display.newSprite(Sprites.sheet, sequenceData)

l.x = 100

l.y = 100

l.width == 100 – assign width here

—whenever this event listener is called and triggers setSequence and play 

– it resizes the control back to its original width

l:addEventListener(“touch”, function(event) 

             print(event.phase)

             if(event.phase==“began”)then 

                  event.target:setSequence(“toggled”)

                  event.target:play()

             end 

           end )

</code>

Hi @pbligh,

For sprites, I would suggest you use scale instead of width/height. Or, you can use a sprite listener and reset the width to 100 every time the frame changes.

Best regards,

Brent

Thank you Brent,

Its good to know there is a way to get around this behavior. 

is this behavior is intentional? why do animated sprites behave in this manner?

Hi @pbligh,

For sprites, I would suggest you use scale instead of width/height. Or, you can use a sprite listener and reset the width to 100 every time the frame changes.

Best regards,

Brent

Thank you Brent,

Its good to know there is a way to get around this behavior. 

is this behavior is intentional? why do animated sprites behave in this manner?