Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Animation Lag
- THECRAZYSANS
- Scratcher
13 posts
Animation Lag
I been having problems with lag in my animations, i just need a code to prevent it
- Cool_Dude2022
- Scratcher
100+ posts
Animation Lag
I been having problems with lag in my animations, i just need a code to prevent it
I can't prevent lag if I don't know what's causing or creating the lag in the first place.
If I remember correctly, the “wait (0) secs” block is limited to 30 fps. This means that unless you use a custom block without screen refresh, or don't use a wait block, you're limited to 30fps. By no means is 30fps good, but people still make it work. You can use math to calculate the duration of an animation like this:
# of frames / frame rate for example if I have 30 frames at 30 fps: 30 / 30 = 1. This means that the duration of the animation will be 1 second.
Source
I'm hoping that this is what you're talking about, but if it's not, then I need more information. Preferably the link to the game along with the detailed description of the problem along with what code do you suspect is causing it.
Last edited by Cool_Dude2022 (March 25, 2024 12:32:49)
Did I help you fix your problem? If so, please nominate my project to be featured!
If my code is used, credit is NOT required
- LUKiCREATE
- Scratcher
17 posts
Animation Lag
Lag in which area? If it is just because the delays between frames are too long, then just decrease the delay, it's not lag. Otherwise I don't know please explain further
Some cool projects
Check out other cool projects here: LUKiGAMES (studio)
Check out other cool projects here: LUKiGAMES (studio)
- THECRAZYSANS
- Scratcher
13 posts
Animation Lag
I been having problems with lag in my animations, i just need a code to prevent it
I can't prevent lag if I don't know what's causing or creating the lag in the first place.
If I remember correctly, the “wait (0) secs” block is limited to 30 fps. This means that unless you use a custom block without screen refresh, or don't use a wait block, you're limited to 30fps. By no means is 30fps good, but people still make it work. You can use math to calculate the duration of an animation like this:
# of frames / frame rate for example if I have 30 frames at 30 fps: 30 / 30 = 1. This means that the duration of the animation will be 1 second.
Source
I'm hoping that this is what you're talking about, but if it's not, then I need more information. Preferably the link to the game along with the detailed description of the problem along with what code do you suspect is causing it.
yeah this is what i'm talking about, thanks for the help!
- MrKingofScratch
- Scratcher
100+ posts
Animation Lag
You may have seen other animations with a “loading” screen. You can make one of your own with this code
I'm not sure exactly how this works, but if i had to guess it's forcing scratch to load all of the costumes by displaying them so that they don't have to be loaded while the animation is playing.
Another technique that might work is splitting the animation into seperate sprites. IDK if this actually works, but I do it for tradition
I hope this helps!
when green flag clickedMake sure that the switch costume block sets it to the SECOND COSTUME.
switch costume to [costume 2 v]
repeat until <(costume #) = [1]>
next costume
end
animation code here
I'm not sure exactly how this works, but if i had to guess it's forcing scratch to load all of the costumes by displaying them so that they don't have to be loaded while the animation is playing.
Another technique that might work is splitting the animation into seperate sprites. IDK if this actually works, but I do it for tradition
I hope this helps!
Last edited by MrKingofScratch (March 25, 2024 22:31:24)
- THECRAZYSANS
- Scratcher
13 posts
Animation Lag
i always wondered how they made the loading screens. thanks for telling me! You may have seen other animations with a “loading” screen. You can make one of your own with this codewhen green flag clickedMake sure that the switch costume block sets it to the SECOND COSTUME.
switch costume to [costume 2 v]
repeat until <(costume #) = [1]>
next costume
end
animation code here
I'm not sure exactly how this works, but if i had to guess it's forcing scratch to load all of the costumes by displaying them so that they don't have to be loaded while the animation is playing.
Another technique that might work is splitting the animation into seperate sprites. IDK if this actually works, but I do it for tradition
I hope this helps!
- Discussion Forums
- » Help with Scripts
- » Animation Lag