Game Development Reference
In-Depth Information
I know what you're thinking: it looks like a big mess of code! Unfortunately, it's an essential little tech-
nical hoop you need to jump through to safely add and remove objects from your game. If you break
it down piece by piece, you'll see that it's not so bad. You can pretty much just copy/paste this code
to use with all your classes.
How Dungeon Maze Adventure works
The logic of the game is programmed in the @qjcakjKja[I]j]can class. In large-scale games, you'll
find that it's usually useful to have one or more classes exclusively handle game logic. Game events
such as collision, picking up items, and winning and losing are all handled best if they're kept in
a single “manager” class. If all the game's logic is in one place, it makes it easy for you to change
and update the code because you don't have to hunt through all your classes to find out where, for
example, you added the code that changes the player's health meter. In earlier projects in this topic,
this was handled by the I]ej class. @qjcakjKja[I]j]can is now taking over that role,
The @qjcakjKja[I]j]can class is bound to the @qjcakjKja symbol. That means that whenever an
instance of @qjcakjKja is on the stage, the @qjcakjKja[I]j]can class also runs. Binding the class to
the symbol was done in the @qjcakjKja Properties by assigning @qjcakjKja[I]j]can in the Class field .
You can open the @qjcakjKja Properties to see this yourself by the selecting the @qjcakjKja symbol in
the Library and clicking the small Properties button on the Library 's bottom menu bar. (The Properties
button looks like an i enclosed in a circle.) Figure 8-15 shows what you will see.
Figure 8-15. You can bind a class to a symbol in the Symbol Properties window.
Search Nedrilad ::

Custom Search