Biggerplay Posted April 29, 2014 Share Posted April 29, 2014 I'm trying to destroy a sprite like thisgem.gem.destroy();Where the first "gem" is an object and the 2nd is the actual sprite. But when that is run in my game it's causing this error. Uncaught TypeError: Cannot read property 'length' of undefined phaser.min.js:6:30774 b.Signal.dispatch phaser.min.js:6:30774 b.Signal.dispatch phaser.min.js:6:29120 b.InputHandler._touchedHandler phaser.min.js:9:17906 b.Pointer.start phaser.min.js:8:23849 b.Mouse.onMouseDown phaser.min.js:8:18347 b.Mouse.start._onMouseDown phaser.min.js:8:17770 I read elsewhere that there have been issues with using destroy and something to do with input handlers? but what could be causing the issue? any ideas? Link to comment Share on other sites More sharing options...
ctmartinez1992 Posted April 29, 2014 Share Posted April 29, 2014 How about killing the sprite, you can try with that, not quite the same thing if i'm not mistaken but, it might be a solution.gem.gem.kill(); Link to comment Share on other sites More sharing options...
Biggerplay Posted April 29, 2014 Author Share Posted April 29, 2014 Kill doesn't cause it to crash, but what about clearing the gem from memory? I thought only by using destroy() it would free the memory up again? Link to comment Share on other sites More sharing options...
ctmartinez1992 Posted April 29, 2014 Share Posted April 29, 2014 You are correct, kill() only changes some variables to "kill" the sprite out of the game and does not remove from memory but, i don't think there is enough information in the original post for me to jump to a conclusion. You can post more information (code, debug screens, better explanation of your code); you can debug deeper into phaser; or you can use groups and recycle sprites using the combo kill()/revive() Sorry if that doesn't help you much but it's what i can do with what you posted and my current knowledge of Phaser. Best of lucks! Link to comment Share on other sites More sharing options...
Biggerplay Posted April 29, 2014 Author Share Posted April 29, 2014 I'm hoping if a sprite is not being referenced from anywhere it's memory would be freed u anyway. Link to comment Share on other sites More sharing options...
Recommended Posts