Hello everyone, I’m having a bug I can’t seem to squash. Short and simple, I have spikes in my game, when the player collides with the spikes, after 2 seconds, the scene will reload. That is working. After the scene reloads, when I collide with the spikes again, I get an error. It shows to be an error in the phaser.min.js file. Below is a GIF I created to show what happens:
I have a Fail Class that specifies what happens when a player fails on a hazard/obstacle. I created a class so that I can have one chunk of code to re-use regardless of what kind of death the player experiences.
Thanks for the quick response. So I attempted that and got rid of the fail() method entirely.
Now I get the error immediately on the first collision with the spikes. Wonder if it has something to do with having a separate class/constructor?
phaser.min.js:1 Uncaught TypeError: i.call is not a function
at initialize.collideSpriteVsGroup (phaser.min.js:1)
at initialize.collideHandler (phaser.min.js:1)
at initialize.collideObjects (phaser.min.js:1)
at initialize.update (phaser.min.js:1)
at initialize.step (phaser.min.js:1)
at initialize.update (phaser.min.js:1)
at initialize.h.emit (phaser.min.js:1)
at initialize.step (phaser.min.js:1)
at initialize.update (phaser.min.js:1)
at initialize.step (phaser.min.js:1)
Somehow this.fail was defined during the first scene run but undefined after restart. But regardless, you wouldn’t want to use this.fail (a Fail instance) as a collision callback; instead you would instantiate a new Fail in the callback.
If you switch to phaser.js then the traces will be a little easier to read.