Animation Lag

id: 750071

category: Help with Scripts

posts: 7

I been having problems with lag in my animations, i just need a code to prevent it

THECRAZYSANS wrote:

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 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

Cool_Dude2022 wrote:

THECRAZYSANS wrote:

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!
You may have seen other animations with a “loading” screen. You can make one of your own with this code

when green flag clicked
switch costume to [costume 2 v]
repeat until <(costume #) = [1]>
next costume
end
animation code here
Make sure that the switch costume block sets it to the SECOND COSTUME.


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!

MrKingofScratch wrote:

You may have seen other animations with a “loading” screen. You can make one of your own with this code

when green flag clicked
switch costume to [costume 2 v]
repeat until <(costume #) = [1]>
next costume
end
animation code here
Make sure that the switch costume block sets it to the SECOND COSTUME.


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!
i always wondered how they made the loading screens. thanks for telling me!