Game Development Reference
In-Depth Information
cqaoo>qppkj*aj]^ha`9b]hoa7
cqaoo>qppkj*]hld]9,*17
lh]u=c]ej>qppkj*reoe^ha9pnqa7
lh]u=c]ej>qppkj*]``ArajpHeopajan$IkqoaArajp*?HE?G( ±
kjLh]u=c]ej>qppkj?he_g%7
y
5. You need an event handler for the lh]u=c]ej>qppkj. Add the following code just below the
aj`C]ia method:
bqj_pekjkjLh]u=c]ej>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
ejep$%7
lh]u=c]ej>qppkj*naikraArajpHeopajan$IkqoaArajp*?HE?G( ±
kjLh]u=c]ej>qppkj?he_g%7
y
6. Save the I]ej*]o file and test the program. The Play Again button appears only at the end of
the game and disappears when you click it (see Figure 5-23). The Guess button is also fully
functional when the game starts again.
Figure 5-23. Give the player the option to play again.
In the previous section, you disabled the Guess button when the game finished. Now that you can play
again, you need to make sure that it's enabled and fully visible when the game starts. You also need
to make sure that the Play Again button isn't visible when the game starts. The three new directives in
the ejep method accomplish this:
cqaoo>qppkj*aj]^ha`9pnqa7
cqaoo>qppkj*]hld]9-7
lh]u=c]ej>qppkj*reoe^ha9b]hoa7
You also added two new directives to the aj`C]ia method:
lh]u=c]ej>qppkj*reoe^ha9pnqa7
lh]u=c]ej>qppkj*]``ArajpHeopajan$IkqoaArajp*?HE?G( ±
kjLh]u=c]ej>qppkj?he_g%7
These directives simply make the Play Again button visible and add its event listener,
kjLh]u=c]ej>qppkj?he_g:
bqj_pekjkjLh]u=c]ej>qppkj?he_g$arajp6IkqoaArajp%6rke`
w
 
Search Nedrilad ::




Custom Search