Game Development Reference
In-Depth Information
* Called from within the update method
*
*/
protected override function scan(delta:Number):void {
if ( m_avatar == null ) {
// scan the area with a radius
// set m_avatar to the nearest one
}
// else we already are in engagement with
// an opponent
}
/**
* Chase the current attacker, if not close enough.
* Called from within the update method
*
*/
protected override function chase(delta:Number):void {
if ( m_avatar != null ) {
// Check if the avatar is still accessible
// or even in the game
// If we determine the avatar is 'far' but still
// within range, we move closer to the avatar.
}
}
}
}
To create one of these monsters would be something like:
var am:ActiveMonster = new ActiveMonster(10, 10, 10, 10, 10);
To highlight an inheritance magic that you should be aware of is that of calling the
update method on an active monster object. The execution goes to the parent class
update method:
am.update();
But the execution drops to the ActiveMonster's implementation of scan and chase
methods because they are overridden and the object is of type ActiveMonster .
After finishing the scan or chase method, the update method continues to execute
normally in the parent's class implementation.
 
Search WWH ::




Custom Search