Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Reverse Loop Sprites
Started by matteocabe Jun 13 2018 11:20 PM

- - - - -
3 replies to this topic
sprites
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

matteocabe

[GLOBAL: userInfoPane.html]
matteocabe
  • Observer

  • 1 posts
  • Corona SDK

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?



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 852 posts
  • Corona SDK

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:

 



[TOPIC: post.html]
#3

carloscosta

[GLOBAL: userInfoPane.html]
carloscosta
  • Contributor

  • 596 posts
  • Corona SDK

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 )


[TOPIC: post.html]
#4

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,631 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: sprites