Jump to content

how to make 10 games in one for museum apps


fioner
 Share

Recommended Posts

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
//-------------------------------------------------------------------------------------------------------------------------------

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
 
Link to comment
Share on other sites

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

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...