Right now, if you use this function, it will always move the chest lid to the opposite position. Sometimes that is useful, but other times you won’t want the chest lid to close just because you told it to open but it was already open. To do this, we’ll use a parameter.
- In the
()
parentheses afterstartLidAnimation
, add a parameter calleddirection
. - Use
:
andString
to specify the parameter’s type. In this case it’s a String, which is any collection of characters in “” quotes. We’ll be using “open” and “close” to make sure the animation goes the right way.