Jump to content

Terminate panda engine completely?


Stephan
 Share

Recommended Posts

Hi all,

Currently I am trying to add a bunch of Panda2 games in my Vue.js SPA where I intend to embed a complete panda.js game in an isolated component. In order to keep the code as clean as possible, I would like to create a new game instance when the component is mounted en destroy it completely then the component is destroyed itself. 

I managed to destroy the canvas and delete the game instance located at window.game. However, it appears that the engine is still running because I am getting a cascade of the following error:

system.js:336 Uncaught ReferenceError: game is not defined
    at Class._run (system.js:336)
    at eval (core.js?b5d7:855)
    at animate (core.js?b5d7:951)

...which means that the engine is still running somehow.

My question: Is there a way to terminate the panda game process?

 

Stephan

Link to comment
Share on other sites

thanx for your quick reply! 😃

Your suggestion works all right and the engineloop is terminated. I still get the following error:

VM10871 input.js:200 Uncaught ReferenceError: game is not defined
    at Class._mouseup (VM10871 input.js:200)
    at eval (core.js?b5d7:855)

Which seems logical, since there are several eventlisteners attached to the window during startup in input.init().

unfortunately I cannot remove these eventlisteners since they have been attached with bind(). As a result I don't have a copy of the exact same instance that was bound to window and removeEventlistener() cannot be used. 😕

 

I could make a few adjustments to the engine to make things work but I am a bit reluctant to do all that and ending up with a separate branch... Another approach would be to keep the instance of window.game available. @enpu: What are your thoughts on this? Is it possible to restart the engine with a new canvas and WEB_GL settings?

Link to comment
Share on other sites

I just added new game.stop() function to dev branch. It will stop the engine completely and remove all event listeners. It also has one parameter, which if you set to true, will also remove the canvas.

game.stop(); // Stop engine completely and remove all event listeners
game.stop(true); / Stop engine and also remove canvas

Let me know how it works

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...