ambidex Posted November 25, 2014 Share Posted November 25, 2014 Couldn't find this in the docs, I would like to add a destructor method to my Scene class (opposite of init()), anyone familiar with the implementation? I would like to clean up after my scenes. Quote Link to comment Share on other sites More sharing options...
enpu Posted November 25, 2014 Share Posted November 25, 2014 There is no builtin method for that, but can't you just run your function before calling game.system.setScene ? Quote Link to comment Share on other sites More sharing options...
ambidex Posted November 25, 2014 Author Share Posted November 25, 2014 This would require every bit of logic which calls setScene to trigger game.scene.destruct(); or another non-core-hack would be overruling game.system.setScene() to add a game.scene.destruct() before actually switching the scene. I was hoping for a more solid solution, but that'll work. Thanks! Quote Link to comment Share on other sites More sharing options...
enpu Posted November 25, 2014 Share Posted November 25, 2014 Hmm i think that's something i can add to core, you think destruct would be proper name for the function, or exit? or something else? Quote Link to comment Share on other sites More sharing options...
ambidex Posted November 25, 2014 Author Share Posted November 25, 2014 As a PHP vetran I'd feel most for destruct, but since `init` is currently the constructor I'd personally go for one of the following: destroy(), exit(), terminate() or deinit() Quote Link to comment Share on other sites More sharing options...
enpu Posted November 25, 2014 Share Posted November 25, 2014 Just pushed commit to develop branch, with new exit method for Scene Quote Link to comment Share on other sites More sharing options...
ambidex Posted November 25, 2014 Author Share Posted November 25, 2014 Sounds awesome! I'm gonna implement that asap in my app. Thanks! .exit(function () { console.log("Flies away"); }) 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.