Reverse Loop Sprites

Hi everybody,

I’m a newbie with Lua and I have a problem.

I’m inserting a sprite of a girl walking, but when I try to loop her back it doesn’t work.

 

 local eroeSheet = graphics.newImageSheet("img/livellocamera/camminata.png", opt) local seqs ={{ name = "runLeft", start = 21, count = 20, time = 800, loopCount = 0, loopDirection ="forward" }, { name = "runRight", start = 1, count = 20, time = 800, loopCount = 1, loopDirection ="forward" } } eroe=display.newSprite(camera,eroeSheet,seqs)

This is my code, am I missing something?

Is this all the code you have? Where and how are you calling the sequences? I would also set both loop count to 0. 

This is a fairly old video but it will give you some ideas:

https://www.youtube.com/watch?v=jdH12BDf5BA

did you read the documentation?

https://docs.coronalabs.com/api/library/display/newSprite.html

It doesn’t mention loopCount=-1

Reading it, the only way i think of doing reverse walking is using frames.

local sequenceData = { { name="runLeft", frames={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }, time=800, loopCount=0 }, { name="runRight", frames={ 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, time=800, loopCount=0 } } local character = display.newSprite( imageSheet, sequenceData )

It’s difficult to help more precisely without a clearer description or demo image of what you’re trying to do, but to make a character face the other way just set xScale to -1.

Is this all the code you have? Where and how are you calling the sequences? I would also set both loop count to 0. 

This is a fairly old video but it will give you some ideas:

https://www.youtube.com/watch?v=jdH12BDf5BA

did you read the documentation?

https://docs.coronalabs.com/api/library/display/newSprite.html

It doesn’t mention loopCount=-1

Reading it, the only way i think of doing reverse walking is using frames.

local sequenceData = { { name="runLeft", frames={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }, time=800, loopCount=0 }, { name="runRight", frames={ 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, time=800, loopCount=0 } } local character = display.newSprite( imageSheet, sequenceData )

It’s difficult to help more precisely without a clearer description or demo image of what you’re trying to do, but to make a character face the other way just set xScale to -1.