Nick Zijlstra
Nick Zijlstra

Reputation: 327

change "speed" for few seconds

So I have an object that moves with "speed" now I set the code that when the object collides with another object the speed of the object decreases. I tried doing so by making the speed change and when the speed changes after 3 seconds change it back to it's original speed.

This is something I tried myself but it doesn't work. Can someone explain me what I am doing wrong, if I'm on the right track or a better way to do this? Thanks in advance

 speed = 10;

 if (c < r0+r1) { 
 lives -=1;

 speed = 5;

 if(speed === 5){
    setTimeout(speed =10 ,3000);
 }

Upvotes: 0

Views: 382

Answers (1)

Rodrigo Siqueira
Rodrigo Siqueira

Reputation: 1154

setTimeout(function() {
    speed = 10 
}, 3000);

Upvotes: 2

Related Questions