Lets take an example here. Lets say you downloaded a youtube video and turned every single frame into a png or jpg file. Now you want to play that entire youtube video in turbowarp by placing a bunch of [switch costume to (frame)] blocks. Before you say "oh just use that one extention" this is just an example. I know i can play youtube videos with an extention but i have other reasons for doing this. For another example that i may use this for, have you ever heard of Five Nights at Freddys? FNaF uses their jumpscares in this way. every frame of the jumpscare is its own png file and it flips between them. so now that you know there are other uses for them whats a good way to make it not lag behind. Im thinking make project load every image behind a blackbox first so every image is preloaded and then do the animation but im not sure just that would work
As for the first example, it doesn’t have to be YouTube. There are two extensions you can use together to import and save any video file in a project, I’ve tested it with mp4s upwards of 15 minutes long and it works perfectly.
As for the second, perhaps wait (1 / (frame rate)) seconds and then next costume in a repeat until loop will be more optimized.
But unless you need transparent backgrounds - e.g., layering a jump scare animation over a regular game screen, which I’m not sure whether or not FNaF even does; it could just be canned animations, there’s only 4 -, just use the two extension approach I just mentioned. There’s zero lag.
With the costume approach, you should use the timer or days since 2000 block like this, otherwise it will go out of sync when the project lags:
reset timer
repeat until <(timer) > (100)> // video length
switch costume to (join [video] (floor of ((timer * 30)) + 1)) // 30 is the framerate
end
1: what are the 2 extentions, and how would i use them?
2; yes fnaf does indeed use transparent jump scare animations.
“Files” and “Videos”. I can send you an example project to show you how the code works if you’d like.
Okay, interesting, thank you for correcting me. It’s been a while since I’ve watched anything related to FNaF’s technical development, I should rewatch some analyses.
Also, regarding the second approach, you actually only need to set the project’s frame rate to whatever’s appropriate, and then have a single next costume block in a loop, now that I think about it.
yes please! thanks!
One moment, I’ll write up the code and send you a link.
Apologies for the wait. This should work:
https://drive.google.com/file/d/1YKDoa56NXditQXJTsBC096llh5LhNo_u/view?usp=sharing
Download the sb3 and load it in the editor. Take some time to read the two custom blocks, and the example script that shows an example video. Keep in mind that the projects frame-rate and resolution will of course affect the video, along with the size and position of the sprite it's being played on.
thx