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