I'm struggling on my code.org platform on how to make a delay, as I'm making a shooter game. When I click I want there to be some sort of reloading happening, so it could take me at least 3000ms to reload.
I heard some things about the timeOut() function, but I'm not sure how to use it. I tried many ways, like keeping the timeout outside the if, and inside the if.
You can use built-in
setTimeOutfunction. As the docs says, it fires the function after the desired time ends. Here I build simple reload functionality for you, space to shoot, a to reload;Here's the Game Lab link; https://studio.code.org/projects/gamelab/ZyXRGRq5hyqcPXYTwcfAPfDihSHCyv1CesSnMBwjMWs