Animation Lag
id: 750071
category: Help with Scripts
posts: 7
THECRAZYSANS
loading
I been having problems with lag in my animations, i just need a code to prevent it
Cool_Dude2022
loading
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.
LUKiCREATE
loading
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
THECRAZYSANS
loading
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
loading
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!
THECRAZYSANS
loading
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!