Hello, and first post - please forgive any transgressions.
I’m running into some odd behavior. I have a Canvas called
Ball which I am planning to use as a prefab.
class Ball extends Phaser.Sprite and it’s all boilerplate from there, so far.
I added that prefab to my
Level canvas. Then I run the game in my browser.
This works fine the first time. However, if I refresh the game, I get an error in the console.
SyntaxError: redeclaration of let Ball line 75096 > scriptElement:1:1 <anonymous> http://localhost:1982/projects/cej/WebContent/ line 75096 > scriptElement:1 fileComplete http://localhost:1982/projects/cej/WebContent/lib/phaser.js:75096 onload http://localhost:1982/projects/cej/WebContent/lib/phaser.js:74672
Uncaught SyntaxError: Identifier 'Ball' has already been declared at <anonymous>:1:1 at Phaser.Loader.fileComplete (phaser.js:75096) at XMLHttpRequest.xhr.onload (phaser.js:74672)
If I close the browser window and open it again, it works again. So I am getting the sense that the ball definition is persisting between page refreshes, but the code to define it is run again. In Phaser.Loader.fileComplete, this is done with a call to
Since this happened so early in the development process I have to figure I’m doing something wrong. But generally I would expect all that kind of data to be flushed on refreshing the page, is there any way I can get this to behave as I expect? Or, how should I approach it differently?
const declarations at the same scope and they did not cause errors. But, interestingly, a
let declaration did cause the same error.