Tufan Posted June 8, 2017 Share Posted June 8, 2017 I get this error when restarting Game state. Quote Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. at new c.BitmapData (http://localhost/phaser.min.js:3:388849) This line causing the error: this.player.healthbar = new HealthBar(this, {x:this.player.x, y:this.player.y-25, height:5, width:50}); It's all fine if i call world.removeAll in the state.shutdown function. shutdown: function(){ this.world.removeAll(); } Why am i have to call world.removeAll after switching states? Shouldn't it clear the game world itself when game.state.start is called? Docs says "but not the Stage, so if you've added your own objects to the Stage they will need managing directly" Is healthbar added to the Stage? If so, What is the stage? I'm using phaser.healthbar plugin to create health bars. Link to comment Share on other sites More sharing options...
samme Posted June 8, 2017 Share Posted June 8, 2017 How are you calling game.state.start (or restart)? Link to comment Share on other sites More sharing options...
Tufan Posted June 9, 2017 Author Share Posted June 9, 2017 21 hours ago, samme said: How are you calling game.state.start (or restart)? Game.js: setTimeout(function(){ this.state.start('MainMenu'); }.bind(this), 1500); MainMenu.js (triggered on click): this.state.start('Game'); Edit: Physics is also started on Game state if i start physics on MainMenu. Is this normal? Link to comment Share on other sites More sharing options...
samme Posted June 9, 2017 Share Posted June 9, 2017 Are you loading images from a different host (non-localhost)? Link to comment Share on other sites More sharing options...
Tufan Posted June 9, 2017 Author Share Posted June 9, 2017 40 minutes ago, samme said: Are you loading images from a different host (non-localhost)? No, all images in the images/ dir. Link to comment Share on other sites More sharing options...
Recommended Posts