Studiocode Tutorials | 3.20 Code Window - Lag Time
In this tutorial we will cover lag time with a code button.
Using lag time means that when I activate a button the instance I'm creating will end the specified number of seconds after I activate the button. When we use lag time the button becomes a one touch button. This means that I do not have to click the button twice to activate and then deactivate the button.
Using lag time with a code button typically means one of two things. The first is that the event or behavior happens in the same amount of time every time such as a shot in basketball. The second is that you don't care about how long the instances actually are because you're just looking to code whether the action happened or not.
To enable lag time I will open the inspector of this miss shot button by double-clicking on it. As you can see I already set a custom lead time for this button of five seconds because I want to see the five seconds before I activate the button.
I will then click on the checkbox for lag time and enter in the number of seconds I desire. In this case I'll go with three seconds because I have 5 seconds of lead time and three seconds of lag time. This button will always create instances that are eight seconds long. You see that the identifier is now a grey diamond rather than a white diamond. The gray color denotes that this is a one touch button.
So now let's code an instance using this button. I'll close my inspector and go into code mode and click on the missed shot code button. At the desired time you'll see that the button itself will fill up from the bottom to the top showing you when the instance will end. I will only have to click on the button one time to get the full eight second instance.
You see the instance is now in my timeline even though I only clicked on the code button a single time.