Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Sprite Animation is so fast !
Started by montaserrqasem Mar 17 2019 02:01 PM

9 replies to this topic
sprite animation

Best Answer cyberparkstudios , 18 March 2019 - 12:32 PM

are you sure you are not confusing the 'loopCount' with the 'time' parameter thomas6 refers to... because loopCount 800 makes me think that you think that is 'time'.

I could be wrong, but 800 for loop count seems out of the ordinary ... add     time = 1000  
 
adding time parameter here just before loopCount
{name = "normalRun", start = 1, count = 8,   time = 1000,   loopCount = 800}

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

montaserrqasem

[GLOBAL: userInfoPane.html]
montaserrqasem
  • Observer

  • 5 posts
  • Corona SDK

Hello World,

 

I started learning Corona yesterday and I am very noob here so please go easy on me!

 

I have a problem with animating a sprite sheet the animation works, but the animation speed is very very fast and I don't know why it's fast like this.

 

Can you please tell me what went wrong?

I am using the jungle-cat example and here's my code:

local centerX = display.contentCenterX
local centerY = display.contentCenterY

local options = {
    width = 512,
    height = 256,
    numFrames = 8,
    sheetContentWidth = 2048,
    sheetContentHeight = 512
    
}

local mySheet = graphics.newImageSheet("sprites-cat-running.png", options);

local sequenceData = {
    {name = "normalRun", start = 1, count = 8, loopCount = 800}}

local animation = display.newSprite(mySheet, sequenceData)
animation.x = centerX
animation.y = centerY

animation:setSequence("normalRun")
animation:play()

animation = nil



[TOPIC: post.html]
#2

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 963 posts
  • Corona SDK

time (optional)

Number. This is the time (in milliseconds) for the entire sequence to animate. If not specified, then the per-frame animation rate will be based on the frame rate of your app.

 

https://docs.coronalabs.com/api/library/display/newSprite.html#sequencedata-required


  • montaserrqasem likes this

[TOPIC: post.html]
#3

montaserrqasem

[GLOBAL: userInfoPane.html]
montaserrqasem
  • Observer

  • 5 posts
  • Corona SDK

I honestly tried to play with this parameter and tried to set it on 1 and 1000000000 and it didn't change the animation speed!



[TOPIC: post.html]
#4

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 963 posts
  • Corona SDK

No worries, I believe you! ;)

 

Try setting it to something more realistic like 1000 to 5000. It's in milliseconds, so 1 would still be blazingly fast of course.



[TOPIC: post.html]
#5

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 561 posts
  • Corona SDK

  Best Answer

are you sure you are not confusing the 'loopCount' with the 'time' parameter thomas6 refers to... because loopCount 800 makes me think that you think that is 'time'.

I could be wrong, but 800 for loop count seems out of the ordinary ... add     time = 1000  
 
adding time parameter here just before loopCount
{name = "normalRun", start = 1, count = 8,   time = 1000,   loopCount = 800}


[TOPIC: post.html]
#6

montaserrqasem

[GLOBAL: userInfoPane.html]
montaserrqasem
  • Observer

  • 5 posts
  • Corona SDK

I also tried that!

 

It's weird and I am freaking out! because my code is very simple and should work perfectly, I have seen tutorials and their code looks exactly like mine!

 

Is the number of the frames in the sheet effects this ? does that mean that I have to have more frames in the picture? because I only have 8 frames.



[TOPIC: post.html]
#7

montaserrqasem

[GLOBAL: userInfoPane.html]
montaserrqasem
  • Observer

  • 5 posts
  • Corona SDK

OMG i copied cyberparkstudios's code and it worked and i compared the 2 codes and found out that i've been writing times instead of time!!

 

I am realy sorry guys.. please forgive me for the trouble!



[TOPIC: post.html]
#8

cyberparkstudios

[GLOBAL: userInfoPane.html]
cyberparkstudios
  • Contributor

  • 561 posts
  • Corona SDK

most common mistakes, especially at first are

misspelling, typos, missing or wrong parameters

and...

scope

 

just my opinion.  keep at it, you will experience a lot more such oversights,.. just don't let it discourage you.  Corona forum is a good place to get help.

 

best of luck in your coding adventures.



[TOPIC: post.html]
#9

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 963 posts
  • Corona SDK

Hey! Don't worry about it at all! I think the last time I had a problem I sent about a hundred posts, before discovering it was just a wi-fi problem!

 

The forum's here to help, and sometimes that means discovering a typo.

 

Keep it up!



[TOPIC: post.html]
#10

montaserrqasem

[GLOBAL: userInfoPane.html]
montaserrqasem
  • Observer

  • 5 posts
  • Corona SDK

Thanks, guys really!! you're the best




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: sprite, animation