You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is starting to feel like a game, but we're kind of shooting fish in a
barrel. To make the interaction feel a little more urgent, the directory should
hide the mole if it hasn't been whac'd after a while.
There are some really direct ways to do this that don't require a lot of code,
but let's do it right!
mole.js
Define no-op methods on the Mole prototype for onHide and onShow
Invoke this.onHide from within the hide method
Invoke this.onShow from within the show method
Define an isHidden method on the Mole prototype that returns true
if the Mole is currently hidden and false otherwise
director.js
Define a onShow method for each mole that hides the mole after a
random delay. (Refer back to scheduleShow for a reminder of how to do
this.) Only hide the mole if it is visible (use the new isHidden method
to check).
When this is done, you'll notice that the moles only re-appear if you whac
them--if they hide themselves, then never come back up again. This is because
we're calling scheduleShow only in onWhack. Really, we want to schedule a
new showing whenever the mole hides (whether because it has been whac'd or
because it hid itself). Fix this bug!
The text was updated successfully, but these errors were encountered:
This is starting to feel like a game, but we're kind of shooting fish in a
barrel. To make the interaction feel a little more urgent, the directory should
hide the mole if it hasn't been whac'd after a while.
There are some really direct ways to do this that don't require a lot of code,
but let's do it right!
mole.js
onHide
andonShow
this.onHide
from within thehide
methodthis.onShow
from within theshow
methodisHidden
method on theMole
prototype that returnstrue
if the Mole is currently hidden and
false
otherwisedirector.js
onShow
method for each mole that hides the mole after arandom delay. (Refer back to
scheduleShow
for a reminder of how to dothis.) Only hide the mole if it is visible (use the new
isHidden
methodto check).
When this is done, you'll notice that the moles only re-appear if you whac
them--if they hide themselves, then never come back up again. This is because
we're calling
scheduleShow
only inonWhack
. Really, we want to schedule anew showing whenever the mole hides (whether because it has been whac'd or
because it hid itself). Fix this bug!
The text was updated successfully, but these errors were encountered: