giorg Posted September 27, 2018 Share Posted September 27, 2018 hi all, I've written this code: let man = this.add.sprite(490, 400).setScale(0.6).play('man'); for (let i = 0; i < 5; i++) { let x = 140 + (186 * i); let x_anim = 47 + (224 - 117); diamonds[i] = this.add.image(x, y, 'd' + (i + 1)).setInteractive().on('pointerdown', function () { man.play('open_' + (i + 1)); man.on('animationcomplete', this.openComplete); this.diamondClicked(diamonds[i]); this.add.sprite(x_anim, y_anim).play('diam' + (i + 1)); }, this); } function openComplete() { this.play('man'); } this generate five diamonds, with the man animation waiting for the user to click them. Whatever I choose, always after second click I get that error "RangeError: Maximum call stack size exceeded". If I comment out this.play('man') inside the openComplete function, I get no errors and I can click all of them, but ofc the man animation waiting is not running anymore. What am I doing wrong? Thanks a lot Link to comment Share on other sites More sharing options...
Recommended Posts