fioner Posted August 3, 2015 Share Posted August 3, 2015 Hy,I'm making a apps for a museum and sometimes rooms have game.Most of game are puzzle (some of them have different behaviors...) and each one have : a back button / help button / state win/loose, a background image .... things like that..... This is what i have made :1 - i have a global object : "figamemusee" it's contain all the function using pixi. (loader / animate / drag / on...) (function($){$.fn.figamemusee = function(params){var requestIdAnimation; .....} 2 - i have a "config.js" : it's return for each game a jsObject with: background image, help texte, images to load, array of position "win" ......(this one is call before the loader inside "figamemusee", it should be a json.... in next version ;-) )3 - Index.html, to make test, with button to load game : (each button got a "game parameter" aka "name of the game"...)function figamestdgo(game){PIXI.loader.reset();$('#figame').html("");$('#figame').figamemusee(game);}4 - During my test, i made different version like this, with the back button ://------------------------------------------------------------------------------------------------ function onDownBack(eventData) {//retour au musée PIXI.loader.reset(); stage.destroy(true);//true kill child renderer.destroy(true); window.cancelAnimationFrame(requestIdAnimation); $('#figame').html(""); } So, i know that renderer.destroy(true); doesn't exist... but when i don't use it : i've got a lot of error in firebug as a animate function doesn't stop talking about children...When i use it, i'va got only one error : TypeError: displayObject is undefined if(!displayObject.visible) //-------------------------------------------------------------------------------------------------------------------------------So how can i kill a instance of game using "good practice" ?..... 'cause : actually, when i play at second, or third game : i can see some lage in introduction or it's the same.... thanks Quote Link to comment Share on other sites More sharing options...
xerver Posted August 3, 2015 Share Posted August 3, 2015 PIXI has .destroy() methods on almost all objects. When you are done with PIXI objects call .destroy() on them and then lose your references so the GC can clean them up. Ideally you would reuse as much as possible, because construction/destruction is expensive in JS 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.