Sets a seed value the gauss, rand, and sphrand functions use to generate random numbers. If you assign a value to the seed then execute the gauss, rand, or sphrand function repeatedly, an identical sequence of random numbers is generated. For clarification, see the example below and .
Ball.translateX = rand(5);
When you rewind the animation, Ball’s translateX attribute receives a random value between 0 and 5, for example, 1.392. When you play the animation, the translateX attribute receives a different random value between 0 and 5 each frame.
When you play the animation again, the translateX attribute receives a value each frame that’s different from the values it received the first time you played the animation. In short, every time the rand(5) executes, it gives a different random value.
if (frame == 1) seed(1); Ball.translateX = rand(5);
if (frame == 1) seed(500); Ball.translateX = rand(5);
seed(1); Ball.translateX = rand(5);
Because you assign a value (1) to the seed before each execution of rand(5), you initialize the random number sequence. The rand(5) function therefore returns the first value of the number sequence each time it executes.