problem with animation time and setFrame

Hi I bought texturePacker and I trying it !

For some strange reason I can set a time param to slow down the animation
I can use SetFrame too.

But I can’t use both together :grimacing: !

local sheetInfo = require("star")
local myImageSheet = graphics.newImageSheet( "star.png", sheetInfo:getSheet() )
local sprite = display.newSprite(myImageSheet, {{frames={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, time=1000}});
sprite:setFrame(3)
sprite:play()

Here is the code.
The setFrame call stop the animation !

If I remove time = 1000 then it works !

It’s because the animation is playing only once, you need to specify that you want it to play indefinetively with the loopCount parameter set to 0:

local sprite = display.newSprite(myImageSheet, {{
   frames = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 
   time = 1000,
   loopCount = 0
}})

And then everything else stills the same.

Hum.

Unfortunately that’s not it !

But I think it must be something like that. A missing parameter!
Until now without optimizing the textures, the use of the 2 parameters simultaneously was possible. It is therefore in the way texturePacker creates the imageSheet that there is a problem!

I’ve put the archive here, if someone want to try.

https://www.hillgreen.app/tmp/coin.zip

There must be a simple solution to the problem because I don’t think I’m the first to use texturePacker :smile:

This fixes it …

local frame
local coinModule = require(‘texturePack.coin’)
local tCoinBank = graphics.newImageSheet(‘texturePack/coin.png’, coinModule:getSheet());
local coin = display.newSprite(tCoinBank, {start=1, count=30, time = 1000, loopCount = 0 });
coin.x = 100
coin.y = 100

frame = coinModule:getFrameIndex(Coin_00010)    
coin:setFrame(frame)
coin:play()

No !
coinModule:getFrameIndex(Coin_00010) return nil and it’s works but do not start at frame 10

coinModule:getFrameIndex(‘Coin_00010’) return 10 but this this it doens’t works.

Sorry, I only tested it to see if it would freeze up when setting frame as in your description of the problem. Never checked to see what the actual frame value was.

check out this link, it might be helpful

maybe try this : this did work on my computer

local coinModule = require(‘texturePack.coin’)
local tCoinBank = graphics.newImageSheet(‘texturePack/coin.png’, coinModule:getSheet());
local sheet = coinModule:getSheet()
local seqData = sheet.sequenceData
local coin = display.newSprite(tCoinBank, seqData)
coin.x = 100
coin.y = 100
coin:setSequence(“ten”)
coin:play()

in your coin.lua add sequenceDtaa table just below the sheetContentHeight

be sure to put a comma after sheetContentHeight then drop in this …

sequenceData =
{
{
name = “one”,
start = 1,
time = 1000,
count = 30,
loopCount = 0,
},
{
name = “ten”,
frames = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3,
4, 5, 6, 7, 8, 9},
time = 1000,
loopCount = 0,
}
},

you of course can add more sequenceData tables to your liking

Hum. Yes.

That’s a nice solution !

Better still would be that the bug is fixed, but I note your solution :+1:!
It’s probably better than rewriting an animation management system :slight_smile:

Thank you !

good luck with your app!

Of course it does. It has nothing to do with texturepacker.

You literally just told the framework to show a specific frame and stop the animation!

https://docs.coronalabs.com/api/type/SpriteObject/setFrame.html

If you mean “start at frame 10” then you need to define a sequence.

Hi SGS

I have tried with sequence

local coinModule = require('texturePack.coin')
local tCoinBank = graphics.newImageSheet('texturePack/coin.png', coinModule:getSheet());
local sequences = {{ name = 'test', start=1, count=30, time = 1000, loopCount = 0 }}
local coin = display.newSprite(tCoinBank, sequences)
coin:setSequence('test')
coin.x = 100
coin.y = 100
coin:setFrame(10)
coin:play()

Same thing ! That doesn’t works.
I’m pretty sure there is a default sequence if you don’t specify one, which is why it doesn’t change anything!

I’d suggest using existing methods that works with this one. I’m not sure if this is a bug in the framework but changing the way it works could cause some unforeseen troubles with the existing projects. If defining different sequences solves the problem, you should go with it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.