Refactor chasing code into a generic target chaser

This commit is contained in:
2014-06-19 17:39:25 -07:00
parent 15c5d2a1df
commit c2e87b0a18

View File

@@ -1020,8 +1020,9 @@ var AISprite = function(game, x, y, key, frame) {
this.chasetarget = function(target, alertedState, movingstate, visual) this.chasetarget = function(target, alertedState, movingstate, visual)
{ {
alertedState = (typeof alertedState == undefined ? alertedState : STATE_ALERTED); alertedState = (typeof alertedState == undefined ? STATE_ALERTED : alertedState);
visual = (typeof visual == undefined ? visual : false); visual = (typeof visual == undefined ? false : visual);
movingstate = (typeof alertedState == undefined ? STATE_NONE : movingstate);
if ( game.physics.arcade.collide(this, target) ) if ( game.physics.arcade.collide(this, target) )
return; return;
@@ -1057,7 +1058,6 @@ var AISprite = function(game, x, y, key, frame) {
this.action_chaseplayer = function() this.action_chaseplayer = function()
{ {
var movingstate = STATE_NONE;
this.chasetarget(player, this.chasetarget(player,
STATE_ALERTED, STATE_ALERTED,
STATE_MOVING | STATE_RUNNING, STATE_MOVING | STATE_RUNNING,