Close #35 : This was resolved by switching from arcade.physics.collide() to arcade.physics.overlap() which provides more reliable results
This commit is contained in:
@@ -327,6 +327,8 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this._object.animations.play(getMovingAnimationName(this._object));
|
this._object.animations.play(getMovingAnimationName(this._object));
|
||||||
}, tween);
|
}, tween);
|
||||||
tween.onComplete.add(function() {
|
tween.onComplete.add(function() {
|
||||||
|
if ( this._object.resetPathOnCollision() == true )
|
||||||
|
return;
|
||||||
this._object.path_index += 1;
|
this._object.path_index += 1;
|
||||||
setMovingState(this._object, getFaceState(this._object));
|
setMovingState(this._object, getFaceState(this._object));
|
||||||
this._object.animations.play(getMovingAnimationName(this._object));
|
this._object.animations.play(getMovingAnimationName(this._object));
|
||||||
@@ -341,6 +343,21 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.path_tweens[0].start();
|
this.path_tweens[0].start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.resetPathOnCollision = function() {
|
||||||
|
var aiSprites = game.state.states.game.aiSprites;
|
||||||
|
var hasBeenReset = false;
|
||||||
|
aiSprites.forEach(function(spr) {
|
||||||
|
if ( hasBeenReset == true )
|
||||||
|
return;
|
||||||
|
if ( game.physics.arcade.collide(spr, this) ) {
|
||||||
|
var last = this.path[this.path.length() - 1];
|
||||||
|
this.path_tween_stop();
|
||||||
|
hasBeenReset = true;
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
return hasBeenReset;
|
||||||
|
}
|
||||||
|
|
||||||
this.path_tween_stop = function()
|
this.path_tween_stop = function()
|
||||||
{
|
{
|
||||||
this.path_tweens.forEach(function(x) {
|
this.path_tweens.forEach(function(x) {
|
||||||
@@ -570,6 +587,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
{
|
{
|
||||||
if ( this.ready_to_update == false )
|
if ( this.ready_to_update == false )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( isSet(this.awareness_effect) ) {
|
if ( isSet(this.awareness_effect) ) {
|
||||||
if ( this.awareness_effect.alive == false ) {
|
if ( this.awareness_effect.alive == false ) {
|
||||||
this.awareness_effect.destroy();
|
this.awareness_effect.destroy();
|
||||||
@@ -617,6 +635,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.animations.destroy();
|
this.animations.destroy();
|
||||||
this.clearWordBubble();
|
this.clearWordBubble();
|
||||||
this.state = STATE_UNAWARE;
|
this.state = STATE_UNAWARE;
|
||||||
|
this.view_distance = parseInt(this.view_distance);
|
||||||
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
||||||
this.hunt_radius = parseInt(this.hunt_radius);
|
this.hunt_radius = parseInt(this.hunt_radius);
|
||||||
this.sprite_can_see_lightmeter = Number(this.sprite_can_see_lightmeter);
|
this.sprite_can_see_lightmeter = Number(this.sprite_can_see_lightmeter);
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ var moonlightDialog = {
|
|||||||
"",
|
"",
|
||||||
"*spit* *cough* *hack* *choke* *gag*",
|
"*spit* *cough* *hack* *choke* *gag*",
|
||||||
"",
|
"",
|
||||||
"Wha whats in this pie?! Its awful!",
|
"Wha... whats in this\npie?! Its awful!",
|
||||||
"Oh, its turnip pie. Someone\nstole all my apples."
|
"Oh, its turnip pie. Someone\nstole all my apples."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ GameState.prototype.update = function()
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if ( this.physics.arcade.collide(x, player) ) {
|
if ( this.physics.arcade.overlap(x, player) ) {
|
||||||
x.setAwarenessEffect(STATE_CONCERNED);
|
x.setAwarenessEffect(STATE_CONCERNED);
|
||||||
} else if ( hasState(x, STATE_LOSTHIM) == false ) {
|
} else if ( hasState(x, STATE_LOSTHIM) == false ) {
|
||||||
x.setAwarenessEffect(STATE_LOSTHIM);
|
x.setAwarenessEffect(STATE_LOSTHIM);
|
||||||
@@ -327,7 +327,7 @@ GameState.prototype.update = function()
|
|||||||
x.setAwarenessEffect(STATE_UNAWARE);
|
x.setAwarenessEffect(STATE_UNAWARE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( this.physics.arcade.collide(x, player) == true )
|
if ( this.physics.arcade.overlap(x, player) == true )
|
||||||
x.setAwarenessEffect(STATE_ALERTED);
|
x.setAwarenessEffect(STATE_ALERTED);
|
||||||
if ( hasState(player, STATE_STEALING) == true &&
|
if ( hasState(player, STATE_STEALING) == true &&
|
||||||
x.sprite_has_treasure == true ) {
|
x.sprite_has_treasure == true ) {
|
||||||
@@ -353,7 +353,7 @@ GameState.prototype.update = function()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( this.physics.arcade.collide(x, player) == true ) {
|
if ( this.physics.arcade.overlap(x, player) == true ) {
|
||||||
delState(player, STATE_STEALING);
|
delState(player, STATE_STEALING);
|
||||||
x.sprite_has_treasure = false;
|
x.sprite_has_treasure = false;
|
||||||
var stolen = moonlightTreasures[x.sprite_treasure];
|
var stolen = moonlightTreasures[x.sprite_treasure];
|
||||||
@@ -388,7 +388,7 @@ GameState.prototype.update = function()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.effectSprites.forEach(_inner_collide, this);
|
// this.effectSprites.forEach(_inner_collide, this);
|
||||||
|
|
||||||
this.aiSprites.forEach(_inner_collide, this);
|
this.aiSprites.forEach(_inner_collide, this);
|
||||||
this.updateShadowTexture();
|
this.updateShadowTexture();
|
||||||
|
|||||||
Reference in New Issue
Block a user