You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using DragonBones to animate some of my characters (e.g. wasps).
I would like to simply restart my game after the player killed all the "wasps" on the screen. What I do for now is simply:
publiconWaspDeath(){console.log("Dead Wasps: "+this._wasps.countDead());if(this._wasps.countLiving()<=1){// the currently killed wasp is not dead yetconsole.log("You killed all the Wasps!")this.game.sound.play("congrats");this.game.state.restart();}}
That lead to this error in Chrome:
Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)'
at i.Image.s.Sprite._renderCanvas (phaser.js:15696)
at a.s.Sprite._renderCanvas (phaser.js:15701)
at i.Group.s.DisplayObjectContainer._renderCanvas (phaser.js:15072)
at i.World.s.DisplayObjectContainer._renderCanvas (phaser.js:15072)
at i.Stage.s.DisplayObjectContainer._renderCanvas (phaser.js:15072)
at s.CanvasRenderer.renderDisplayObject (phaser.js:20563)
at s.CanvasRenderer.render (phaser.js:20488)
at Game.updateRender (phaser.js:36186)
at Game.update (phaser.js:36102)
at i.RequestAnimationFrame.updateRAF (phaser.js:64166)
I added a conditional breakpoint before the problematic function call, so that I can check the parameter passed to that function when the game restarts.
So basically, with this method, I could see what this.texture.baseTexture.source is returning just after I called this.game.state.restart().
Note that the problematic function renderSession.context.drawImage() in part of a loop that iterates over the objects to display.
Here the results:
At the third iteration, for some reason this.texture.baseTexture.source is null. That means that my third object to be displayed is null.
After trying to find out which object was that third object, I start to think that it might be the wasp that I animated with DragonBones... So basically the wasp would load correctly when running the game, but it would fail to load when restarting the current phaser state.
Any body has already encountered a similar problem with DragonBones and Phaser?
Thank you very much for your help.
The text was updated successfully, but these errors were encountered:
Ok so it seems that to write this issue helped me to find a solution :)
I just needed to add one line of code to reset the DragonBones factory:
publiconWaspDeath(){console.log("Dead Wasps: "+this._wasps.countDead());if(this._wasps.countLiving()<=1){console.log("You killed all the Wasps!")this.game.sound.play("congrats");this._db_factory.clear();// IMPORTANT CHANGEthis.game.state.restart();}}
Hello,
I am using DragonBones to animate some of my characters (e.g. wasps).
I would like to simply restart my game after the player killed all the "wasps" on the screen. What I do for now is simply:
That lead to this error in Chrome:
I added a conditional breakpoint before the problematic function call, so that I can check the parameter passed to that function when the game restarts.
So basically, with this method, I could see what this.texture.baseTexture.source is returning just after I called this.game.state.restart().
Note that the problematic function renderSession.context.drawImage() in part of a loop that iterates over the objects to display.
Here the results:
At the third iteration, for some reason this.texture.baseTexture.source is null. That means that my third object to be displayed is null.
After trying to find out which object was that third object, I start to think that it might be the wasp that I animated with DragonBones... So basically the wasp would load correctly when running the game, but it would fail to load when restarting the current phaser state.
Any body has already encountered a similar problem with DragonBones and Phaser?
Thank you very much for your help.
The text was updated successfully, but these errors were encountered: