tips4design Posted October 18, 2017 Share Posted October 18, 2017 I have to destroy a PIXI app and create it later on the same page, but it doesn't seem to work. No error is thrown but it simply doesn't show anything after the restart. Here is the edited basic example (https://pixijs.github.io/examples/#/basics/basic.js ): var app; function create() { app = new PIXI.Application(800, 600, {backgroundColor : 0x1099bb}); document.body.appendChild(app.view); // create a new Sprite from an image path var bunny = PIXI.Sprite.fromImage('required/assets/basics/bunny.png') // center the sprite's anchor point bunny.anchor.set(0.5); // move the sprite to the center of the screen bunny.x = app.renderer.width / 2; bunny.y = app.renderer.height / 2; app.stage.addChild(bunny); // Listen for animate update app.ticker.add(function(delta) { // just for fun, let's rotate mr rabbit a little // delta is 1 if running at 100% performance // creates frame-independent tranformation bunny.rotation += 0.1 * delta; }); console.log(PIXI); } create(); setTimeout(() => { app.destroy(); setTimeout(create, 200); }, 1000); Quote Link to comment Share on other sites More sharing options...
tips4design Posted October 18, 2017 Author Share Posted October 18, 2017 Nevermind, the issue is that the old canvas is still there, so the new canvas is added below it. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.