@@ -276,8 +276,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
276276 * @param {cc.SpriteBatchNode } batchNode
277277 */
278278 useBatchNode : function ( batchNode ) {
279- this . textureAtlas = batchNode . getTextureAtlas ( ) ; // weak ref
280- this . _batchNode = batchNode ;
281279 } ,
282280
283281 /**
@@ -299,94 +297,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
299297 this . _renderCmd . setDirtyFlag ( cc . Node . _dirtyFlags . transformDirty ) ;
300298 } ,
301299
302- /**
303- * Sort all children of this sprite node.
304- * @override
305- */
306- sortAllChildren : function ( ) {
307- if ( this . _reorderChildDirty ) {
308- var _children = this . _children ;
309-
310- cc . Node . prototype . sortAllChildren . call ( this ) ;
311-
312- if ( this . _batchNode ) {
313- this . _arrayMakeObjectsPerformSelector ( _children , cc . Node . _stateCallbackType . sortAllChildren ) ;
314- }
315-
316- //don't need to check children recursively, that's done in visit of each child
317- this . _reorderChildDirty = false ;
318- }
319-
320- } ,
321-
322- /**
323- * Reorders a child according to a new z value. (override cc.Node )
324- * @param {cc.Node } child
325- * @param {Number } zOrder
326- * @override
327- */
328- reorderChild : function ( child , zOrder ) {
329- cc . assert ( child , cc . _LogInfos . Sprite_reorderChild_2 ) ;
330- if ( this . _children . indexOf ( child ) === - 1 ) {
331- cc . log ( cc . _LogInfos . Sprite_reorderChild ) ;
332- return ;
333- }
334-
335- if ( zOrder === child . zIndex )
336- return ;
337-
338- if ( this . _batchNode && ! this . _reorderChildDirty ) {
339- this . _setReorderChildDirtyRecursively ( ) ;
340- this . _batchNode . reorderBatch ( true ) ;
341- }
342- cc . Node . prototype . reorderChild . call ( this , child , zOrder ) ;
343- } ,
344-
345- /**
346- * Removes a child from the sprite.
347- * @param child
348- * @param cleanup whether or not cleanup all running actions
349- * @override
350- */
351- removeChild : function ( child , cleanup ) {
352- if ( this . _batchNode )
353- this . _batchNode . removeSpriteFromAtlas ( child ) ;
354- cc . Node . prototype . removeChild . call ( this , child , cleanup ) ;
355- } ,
356-
357- /**
358- * Removes all children from the container.
359- * @param cleanup whether or not cleanup all running actions
360- * @override
361- */
362- removeAllChildren : function ( cleanup ) {
363- var locChildren = this . _children , locBatchNode = this . _batchNode ;
364- if ( locBatchNode && locChildren != null ) {
365- for ( var i = 0 , len = locChildren . length ; i < len ; i ++ )
366- locBatchNode . removeSpriteFromAtlas ( locChildren [ i ] ) ;
367- }
368-
369- cc . Node . prototype . removeAllChildren . call ( this , cleanup ) ;
370- this . _hasChildren = false ;
371- } ,
372-
373300 //
374301 // cc.Node property overloads
375302 //
376303
377- /**
378- * Sets whether ignore anchor point for positioning
379- * @param {Boolean } relative
380- * @override
381- */
382- ignoreAnchorPointForPosition : function ( relative ) {
383- if ( this . _batchNode ) {
384- cc . log ( cc . _LogInfos . Sprite_ignoreAnchorPointForPosition ) ;
385- return ;
386- }
387- cc . Node . prototype . ignoreAnchorPointForPosition . call ( this , relative ) ;
388- } ,
389-
390304 /**
391305 * Sets whether the sprite should be flipped horizontally or not.
392306 * @param {Boolean } flippedX true if the sprite should be flipped horizontally, false otherwise.
@@ -494,18 +408,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
494408 return this . _batchNode ;
495409 } ,
496410
497- _setReorderChildDirtyRecursively : function ( ) {
498- //only set parents flag the first time
499- if ( ! this . _reorderChildDirty ) {
500- this . _reorderChildDirty = true ;
501- var pNode = this . _parent ;
502- while ( pNode && pNode !== this . _batchNode ) {
503- pNode . _setReorderChildDirtyRecursively ( ) ;
504- pNode = pNode . parent ;
505- }
506- }
507- } ,
508-
509411 // CCTextureProtocol
510412 /**
511413 * Returns the texture of the sprite node
@@ -856,20 +758,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
856758 * layer.addChild(batch);
857759 */
858760 setBatchNode : function ( spriteBatchNode ) {
859- var _t = this ;
860- _t . _batchNode = spriteBatchNode ; // weak reference
861-
862- // self render
863- if ( ! _t . _batchNode ) {
864- _t . atlasIndex = cc . Sprite . INDEX_NOT_INITIALIZED ;
865- _t . textureAtlas = null ;
866- _t . _recursiveDirty = false ;
867- _t . dirty = false ;
868- } else {
869- // using batch
870- _t . _transformToBatch = cc . affineTransformIdentity ( ) ;
871- _t . textureAtlas = _t . _batchNode . getTextureAtlas ( ) ; // weak ref
872- }
873761 } ,
874762
875763 // CCTextureProtocol
0 commit comments