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));
|
||||
}, tween);
|
||||
tween.onComplete.add(function() {
|
||||
if ( this._object.resetPathOnCollision() == true )
|
||||
return;
|
||||
this._object.path_index += 1;
|
||||
setMovingState(this._object, getFaceState(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.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_tweens.forEach(function(x) {
|
||||
@@ -570,6 +587,7 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
{
|
||||
if ( this.ready_to_update == false )
|
||||
return;
|
||||
|
||||
if ( isSet(this.awareness_effect) ) {
|
||||
if ( this.awareness_effect.alive == false ) {
|
||||
this.awareness_effect.destroy();
|
||||
@@ -617,6 +635,7 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
this.animations.destroy();
|
||||
this.clearWordBubble();
|
||||
this.state = STATE_UNAWARE;
|
||||
this.view_distance = parseInt(this.view_distance);
|
||||
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
||||
this.hunt_radius = parseInt(this.hunt_radius);
|
||||
this.sprite_can_see_lightmeter = Number(this.sprite_can_see_lightmeter);
|
||||
|
||||
@@ -269,7 +269,7 @@ var moonlightDialog = {
|
||||
"",
|
||||
"*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."
|
||||
]
|
||||
},
|
||||
|
||||
@@ -319,7 +319,7 @@ GameState.prototype.update = function()
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if ( this.physics.arcade.collide(x, player) ) {
|
||||
if ( this.physics.arcade.overlap(x, player) ) {
|
||||
x.setAwarenessEffect(STATE_CONCERNED);
|
||||
} else if ( hasState(x, STATE_LOSTHIM) == false ) {
|
||||
x.setAwarenessEffect(STATE_LOSTHIM);
|
||||
@@ -327,7 +327,7 @@ GameState.prototype.update = function()
|
||||
x.setAwarenessEffect(STATE_UNAWARE);
|
||||
}
|
||||
}
|
||||
if ( this.physics.arcade.collide(x, player) == true )
|
||||
if ( this.physics.arcade.overlap(x, player) == true )
|
||||
x.setAwarenessEffect(STATE_ALERTED);
|
||||
if ( hasState(player, STATE_STEALING) == true &&
|
||||
x.sprite_has_treasure == true ) {
|
||||
@@ -353,7 +353,7 @@ GameState.prototype.update = function()
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( this.physics.arcade.collide(x, player) == true ) {
|
||||
if ( this.physics.arcade.overlap(x, player) == true ) {
|
||||
delState(player, STATE_STEALING);
|
||||
x.sprite_has_treasure = false;
|
||||
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.updateShadowTexture();
|
||||
|
||||
Reference in New Issue
Block a user