RobCowell Posted January 28, 2014 Share Posted January 28, 2014 I'm doing something odd with Phaser (and Codef too, which I know Rich tinkers with too...) by combining it with impress.js (https://github.com/bartaz/impress.js/) so that I can have a Prezi-style slideshow with funky animated slides. So on each slide I have a div for hosting a canvas generated by Phaser and I'm hooking into the enter/exit events of the slide transitions so I can clear down the old effect and then set up the next one (too many FX, not enough CPU otherwise). What's the best way to "clear down" a Phaser instance? Currently I have something like :- function stopPlasma(){game.destroy();Phaser.SoundManager.context = null;background = null;filter = null;$('#plasma canvas').remove();}which is working for the graphical side of things, but still leaves an open instance of WebAudio (not that I'm using any audio in this case). Switching slides back and forth ends up with me having too many instances of it and it bombs out Uncaught SyntaxError: Failed to construct 'AudioContext': number of hardware contexts reached maximum (4). phaser.js:33291Phaser.SoundManager.bootphaser.js:33291Phaser.Game.bootphaser.js:13020_onBootphaser.js:12949 Any hints to be had here? See what I mean at http://www.alphatron.co.uk/~robcowell/Heroku2 and switch back and forth between slides 2 and 3 a few times (Chrome highly recommended for this) Thanks Rob Link to comment Share on other sites More sharing options...
RobCowell Posted January 30, 2014 Author Share Posted January 30, 2014 So the answer seems to bethis.webkitAudioContext = null;which switches the audio renderer for subsequent instances to HTML Audio. Not ideal in all use cases, but since I'm not pushing any audio myself, it solves my immediate need. I do move on to the warning about webGL contexts, but it is just a warning and it tidies up behind itself anyway Link to comment Share on other sites More sharing options...
Recommended Posts