-
24 Jan 2012 1:36 PM #1
CompositeSprite destruction
CompositeSprite destruction
I do a lot of work with composite sprites. I simplified the current destroy() method, which also should be a little faster. I just skipped the getCount() call, which is not needed since first() will return null if there are no more sprites to be destroyed.
Code:// current destroy: function(){ var me = this, surface = me.getSurface(), item; if (surface) { while (me.getCount() > 0) { item = me.first(); me.remove(item); surface.remove(item); } } me.clearListeners(); } // modified destroy: function(){ var me = this, surface = me.getSurface(), item; if (surface) { while (item = me.first()) { me.remove(item); surface.remove(item); } } me.clearListeners(); }
-
12 Feb 2012 5:33 AM #2
Can we turn this into a ticket? This small change will improve performance and reduce code size.
-
13 Feb 2012 6:33 AM #3
Missing param
Missing param
... and the 2nd param in the call to surface.remove is missing (still not fixed as of B2)
Let's create a ticket, thank you
Code:// modified destroy: function(){ var me = this, surface = me.getSurface(), item; if (surface) { while (item = me.first()) { me.remove(item); surface.remove(item, true); } } me.clearListeners(); }
-
13 Feb 2012 6:58 AM #4
I overrode the CompositeSprite.destroy method. Now that I'm actually destroying the sprites it takes a lot longer to destroy the group. This is bad, but we need to properly destroy the sprites.
Code:Ext.define('wag.override.draw.CompositeSprite', { override: 'Ext.draw.CompositeSprite', destroy: function () { var me = this, surface = me.getSurface(), item; if (surface) { while (item = me.first()) { me.remove(item); surface.remove(item, true); } } me.clearListeners(); } });


Reply With Quote