Game Development Reference
In-Depth Information
protected function checkInventory(name:String):Boolean {
var found:Boolean = false;
for (var i:int = 0; i < _inventory.length; i++) {
if (_inventory[i].name == name) {
found = true;
return found;
When the use key is pressed, the engine runs the checkPortals
method. This not only tests to see if the player is colliding with a
portal, but it checks the portal
s requirement list to make sure the
player has completed the requirements for passing through the
for is an inventory item. The checkInventory method is called to see
if an item with the specified name is in the player
s inventory. If it
is, the requirement is met and the player is allowed access to the
protected function render():void {
if (!_gameRunning) return;
_player.x = _player.tempX;
_player.y = _player.tempY;
for each (var enemy:IEnemy in _enemies) {
enemy.x = enemy.tempX;
enemy.y = enemy.tempY;
The final method of the engine class updates the player
all enemies
x and y positions to their corrected temp values. It
also calls the update method on both of these types of objects.
This allows animation/graphic updates in those types of Sprites to
occur regularly and without having to call any specific code. Now,
ve discussed the entire engine package
next, we
ll review the
game classes that put this engine into action.
Search Nedrilad ::

Custom Search