Game Development Reference
In-Depth Information
m_life -= damage;
if ( isDead() ) {
death();
}
}
}
We simply add an
if
condition to check whether we are already engaged in a battle
with an attacker; in that case, we don't update the attacker.
Note that with a simple change like shown previously, we are able to create a
monster with different behavior and reuse most of the code in our base
Monster class.
So it's time to create the subclass for the passive monster. To do so, we right-click
on the folder that we want the file to be placed under and select
ActionScript Class
under the
New
menu item. Enter
PassiveMonster
for the
Name:
and also
Monster
for
Superclass:
as shown next: