# Is this a bug with ImageSheets?

**URL:** <https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332>\
**Category:** Uncategorized\
**Created:** [March 10, 2013, 7:32pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332 "2013-03-10T19:32:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aidin](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aidin](https://forums.solar2d.com/u/Aidin)\
**Post date:** [March 10, 2013, 7:32pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332/1 "2013-03-10T19:32:55Z")

</div>

Hi,

I load my ImageSheet like this:

[lua]

local newTongue = {};

local sheetData =  
{  
width = 53,  
height = 10,  
numFrames = 2,

– The params below are optional; used for dynamic resolution support  
sheetContentWidth = 106, – width of original 1x size of entire sheet  
sheetContentHeight = 10, – height of original 1x size of entire sheet  
}

local sequenceData = {  
{ name = “start2”, frames={ 1, 2}, time = 250, loopCount = 1 },  
}

local mySheet = graphics.newImageSheet(“tongue\_left.png”, sheetData );  
newTongue = display.newSprite(mySheet, sequenceData)  
[/lua]

and play it back like this:

[lua]  
newTongue:setSequence(“start2”)  
newTongue:play()  
[/lua]

Problem is, sprite sheet get’s loaded but won’t animate. Unless I increase frames of the sequence data’s frames to like {1,2,1} or make loopCount to 2 or more. And if I make loopCount to 2, it won’t play the animation back 2 times, it gets played back infinitely!

My image file that I’m loading is sized at 106x10 and has two frames and each frame is 53x10.

What’s the problem?

Thanks. [import]uid: 206803 topic\_id: 37379 reply\_id: 67379[/import]

---

<div class="post-metadata">

**Author:** ![Aidin](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aidin](https://forums.solar2d.com/u/Aidin)\
**Post date:** [March 10, 2013, 8:58pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332/2 "2013-03-10T20:58:44Z")

</div>

Probably problem is highly related to loopCount because if I remove it, it works but when I put it and give it 1, it won’t.

You may think that animation is played back so fast that I can’t see but I press Ctrl+R fast and can’t see a thing. [import]uid: 206803 topic\_id: 37379 reply\_id: 145571[/import]

---

<div class="post-metadata">

**Author:** ![Aidin](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aidin](https://forums.solar2d.com/u/Aidin)\
**Post date:** [March 10, 2013, 9:13pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332/3 "2013-03-10T21:13:33Z")

</div>

Problem was with the animation listener. I accidentally copied my listener from another class and in it I set another animation and play back. Since Corona didn’t complain about this ImageSheet not having that animation, I didn’t notice. Nothing in the terminal.

BTW, I still think there is a problem there with loopCount because with that animation listener there I still can’t get one loop out of my animation and my animation listener doesn’t stop any animation but when it’s there, I can’t get animation to be played back once. Because if it was with the animation listener, it would not work with the loopCount of 2.

[lua]

local function mySpriteListener( event )

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

if (event.target.sequence == “MajorChew”) then

numOfMonstersThatDoneChewing = numOfMonstersThatDoneChewing + 1

end

local thisSprite = event.target --“event.target” references the sprite  
thisSprite:setSequence( “idle” ) --switch to “fastRun” sequence  
thisSprite:play() --play the new sequence; it won’t play automatically!  
end

end  
[/lua] [import]uid: 206803 topic\_id: 37379 reply\_id: 145574[/import]

---

<div class="post-metadata">

**Author:** ![Aidin](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aidin](https://forums.solar2d.com/u/Aidin)\
**Post date:** [March 10, 2013, 8:58pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332/4 "2013-03-10T20:58:44Z")

</div>

Probably problem is highly related to loopCount because if I remove it, it works but when I put it and give it 1, it won’t.

You may think that animation is played back so fast that I can’t see but I press Ctrl+R fast and can’t see a thing. [import]uid: 206803 topic\_id: 37379 reply\_id: 145571[/import]

---

<div class="post-metadata">

**Author:** ![Aidin](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@Aidin](https://forums.solar2d.com/u/Aidin)\
**Post date:** [March 10, 2013, 9:13pm UTC](https://forums.solar2d.com/t/is-this-a-bug-with-imagesheets/311332/5 "2013-03-10T21:13:33Z")

</div>

Problem was with the animation listener. I accidentally copied my listener from another class and in it I set another animation and play back. Since Corona didn’t complain about this ImageSheet not having that animation, I didn’t notice. Nothing in the terminal.

BTW, I still think there is a problem there with loopCount because with that animation listener there I still can’t get one loop out of my animation and my animation listener doesn’t stop any animation but when it’s there, I can’t get animation to be played back once. Because if it was with the animation listener, it would not work with the loopCount of 2.

[lua]

local function mySpriteListener( event )

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

if (event.target.sequence == “MajorChew”) then

numOfMonstersThatDoneChewing = numOfMonstersThatDoneChewing + 1

end

local thisSprite = event.target --“event.target” references the sprite  
thisSprite:setSequence( “idle” ) --switch to “fastRun” sequence  
thisSprite:play() --play the new sequence; it won’t play automatically!  
end

end  
[/lua] [import]uid: 206803 topic\_id: 37379 reply\_id: 145574[/import]
