Game Development Reference
In-Depth Information
In the previous example, [_heajpD]oIkjauEj=__kqjp is b]hoa, so the cap method returns b]hoa. The
poor client's [d]oIkjau property then also gets a value of b]hoa. pnqa and b]hoa are Boolean values,
so you need to include this information as part of the function definition:
bqj_pekjcapceraIkjauPk?heajp$%6 >kkha]j
The result of all this is bad for the client, but great for the bank, and actually reflects the reality of the
situation. Using the cap method prevented the client from directly changing one of the bank's prop-
erties and the bank from being robbed. It's this kind of careful programming that that will save your
games from strange bugs that might be extremely difficult to trace or track down.
As you might have guessed, cap methods are affectionately known as getters .
Using setters
Getters have partners in crime called setters . Setters use the oap keyword and are used by an object
to receive information from another object.
Hooray! The client just a received a check in the mail for a Flash game she designed! Let's have a look
at how you could use a setter to help the impoverished client put this money into the bank:
lq^he__h]oo?heajp
w
lner]par]n[_da_gR]hqa9-,,7
lq^he_bqj_pekj?heajp$%
w
>]jg*`alkoep9[_da_gR]hqa7
y
y
Here's what the >]jg class looks like, featuring a setter called `alkoep:
lq^he__h]oo>]jg
w
lner]par]n[_heajp=__kqjpR]hqa9,7
lq^he_op]pe_bqj_pekjoap`alkoep$ikjau6ejp%6rke`
w
eb$ikjau:,%
w
[_heajp=__kqjpR]hqa'9ikjau7
y
y
y
 
Search Nedrilad ::




Custom Search