Sprite Animation is Skipping Frames

Got a weird problem – I have a sprite animation that is skipping frames, or stuttering somehow. I threw in some code to track what was going on…

sequenceData = {{ name="swim", start=sheetInfo:getFrameIndex("mermaid01"), count=9, time=550 }, { name="idle", start=sheetInfo:getFrameIndex("mermaid01"), count=9, time=1100 }} player = display.newSprite( foregroundLayer, myImageSheet, sequenceData ) local function spriteListener(event) if event.phase == "loop" or event.phase == "next" then print("Player ", event.phase, player.frame) end end player:addEventListener ( "sprite", spriteListener )

…and what I’m getting is something like below. Notice that the first seven times every frame is being played, but after that it goes off into the weeds.

Has anybody seen anything like this before? (Using build 2016.2916)

 Jay

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 2  ??? missing loop

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 9

Player loop 1  <–

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 2  ??? just a mess from here until I stopped it

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 2

Player next 3

Player next 4

Player next 2

Player next 3

Player next 2

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 2

Player next 3

Player next 4

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 2

Player next 3

Player next 2

Player next 3

Player next 4

Player next 2

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 7

Player next 8

Player next 2

Player next 3

Player next 2

Player next 3

Player next 4

Player next 5

Player next 6

Player next 2

Player next 3

Player next 2

Player next 3

What does you start=sheetInfo:getFrameIndex(mermaid01) equal, this is the only reason I can think of why this is happening.

Can you post a picture of your image sheet?

The getFrameIndex thing returns 22, which is the correct index into the table of sprites.

Here’s what the image sheet looks like:

spritesheet01.png

This is indeed an odd situation. What happens if you slow your frame rate down to 30fps? I’m assuming you’re at 60fps.  If you are at 30, what happens at 60fps?

Does this happen on a device of just the simulator?

Have you rebooted recently? I’m working on a game in my spare time and for a couple of days when the app started, the frame rate was awful right after I saved a file in my editor or CTRL-R(CMD-R)'s the simulator. I didn’t measure it, but it would like pause, run at 30fps for a fraction of a second and pause again. But if I let the game play for 10-15 seconds the frame rate worked its way up. I decided to reboot my MacBook Pro and after that, the game hums a long nicely. I’m thinking a browser had consumed an insane amount of memory or something. So look for external causes if it’s in the simulator as well.

Rob

I’m at 60fps and it happens on the device as well as the simulator (so I don’t think rebooting will help). I didn’t try 30fps on the device, but the problem is still there at that rate in the simulator.

I have three Runtime event listeners:

  • enterFrame just looks to see if an object is active and if so, changes the x/y coords of it.
  • key looks for keypresses, but the dropped frames are also happening when the player is just sitting there.
  • touch looks for a swipe on the screen to move the player.

I don’t think any of those would be sucking up enough juice to make a difference.

Any other suggestions? Or is it time for me to try and make a tiny project that shows the problem? :slight_smile:

 Jay

I would say it’s time to make a simpler project.

Rob

What does you start=sheetInfo:getFrameIndex(mermaid01) equal, this is the only reason I can think of why this is happening.

Can you post a picture of your image sheet?

The getFrameIndex thing returns 22, which is the correct index into the table of sprites.

Here’s what the image sheet looks like:

spritesheet01.png

This is indeed an odd situation. What happens if you slow your frame rate down to 30fps? I’m assuming you’re at 60fps.  If you are at 30, what happens at 60fps?

Does this happen on a device of just the simulator?

Have you rebooted recently? I’m working on a game in my spare time and for a couple of days when the app started, the frame rate was awful right after I saved a file in my editor or CTRL-R(CMD-R)'s the simulator. I didn’t measure it, but it would like pause, run at 30fps for a fraction of a second and pause again. But if I let the game play for 10-15 seconds the frame rate worked its way up. I decided to reboot my MacBook Pro and after that, the game hums a long nicely. I’m thinking a browser had consumed an insane amount of memory or something. So look for external causes if it’s in the simulator as well.

Rob

I’m at 60fps and it happens on the device as well as the simulator (so I don’t think rebooting will help). I didn’t try 30fps on the device, but the problem is still there at that rate in the simulator.

I have three Runtime event listeners:

  • enterFrame just looks to see if an object is active and if so, changes the x/y coords of it.
  • key looks for keypresses, but the dropped frames are also happening when the player is just sitting there.
  • touch looks for a swipe on the screen to move the player.

I don’t think any of those would be sucking up enough juice to make a difference.

Any other suggestions? Or is it time for me to try and make a tiny project that shows the problem? :slight_smile:

 Jay

I would say it’s time to make a simpler project.

Rob