sinanqd10 Posted January 13, 2015 Share Posted January 13, 2015 I want to destroy a function, what is the best way to do that? example :FavoriteFlavor.bootState = { button: function(btnX, btnY, textX, textY, fn, text) { var button = game.add.button(game.world.centerX + btnX, game.world.centerY + btnY, 'btnLetGo', fn, this); button.anchor.set(0.5); button.input.useHandCursor = true; var letGo = game.add.text(game.world.centerX + textX, game.world.centerY + textY, text); letGo.font = 'Arial'; letGo.fill = '#ffffff'; letGo.fontSize = '13px'; letGo.align = 'center'; letGo.fontWeight = 'bold'; letGo.anchor.set(0.5); }};FavoriteFlavor.gameState.prototype = { create: function() { button = FavoriteFlavor.bootState.button(0, 130, 0, 130, this.start, "Start"); }, start: function() { //click start function destory FavoriteFlavor.bootState.button //how to do that? }}; Link to comment Share on other sites More sharing options...
Taleforge Posted January 13, 2015 Share Posted January 13, 2015 If you really want to destroy the function (I guess its not what you want)do "delete FavoriteFlavor.bootState.button". If you want to remove the button you have to store a reference (for example "this.button") to the button and than call "destroy" on it. So, what exactly should happen? Link to comment Share on other sites More sharing options...
Recommended Posts