Skip to content

Commit 51c064d

Browse files
committed
Update dog behavior to fix #27 and fix #33
1 parent 139e35d commit 51c064d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/modules/Dog.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Dog extends Character {
4343
];
4444
super('dog', options.spritesheet, states);
4545
this.toRetrieve = 0;
46+
this.maxRetrieve = 3;
4647
this.anchor.set(0.5, 0);
4748
this.options = options;
4849
this.sniffSoundId = null;
@@ -191,8 +192,11 @@ class Dog extends Character {
191192
* @retuns {Dog}
192193
*/
193194
retrieve() {
195+
// To avoid ridiculous chains of animations that last forever we can limit this a bit
196+
if (this.toRetrieve + 1 >= this.maxRetrieve) {
197+
return this;
198+
}
194199
this.toRetrieve++;
195-
196200
this.upDownTween({
197201
onStart: () => {
198202
if (this.toRetrieve >= 2) {
@@ -212,10 +216,10 @@ class Dog extends Character {
212216
* @returns {Dog}
213217
*/
214218
laugh() {
219+
this.toRetrieve=0;
215220
this.upDownTween({
216221
state: 'laugh',
217222
onStart: () => {
218-
this.toRetrieve = 0;
219223
this.state = 'laugh';
220224
sound.play('laugh');
221225
}

src/modules/Stage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class Stage extends Container {
220220
* @returns {Promise} - This promise is resolved when all the ducks have flown away
221221
*/
222222
flyAway() {
223+
this.dog.stopAndClearTimeline()
223224
this.dog.laugh();
224225

225226
const duckPromises = [];

0 commit comments

Comments
 (0)