Skip to content

Commit

Permalink
UPD cleanup HSpriteBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Oct 24, 2024
1 parent 9858b29 commit 53f80ad
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/dn/heaps/slib/HSpriteBatch.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ class HSpriteBatch extends h2d.SpriteBatch {

override function onAdd(){
super.onAdd();
var c = first;
while( c != null ){
if( Std.isOfType(c,HSpriteBE) )
(cast c:HSpriteBE).onAdd();
c = c.next;
var e = first;
while( e != null ){
if( Std.isOfType(e,HSpriteBE) )
Std.downcast(e, HSpriteBE).onAdd();
e = e.next;
}
}

override function onRemove(){
super.onRemove();
var c = first;
while( c != null ){
if( Std.isOfType(c,HSpriteBE) )
(cast c:HSpriteBE).onRemove();
c = c.next;
var e = first;
while( e != null ){
if( Std.isOfType(e,HSpriteBE) )
Std.downcast(e, HSpriteBE).onRemove();
e = e.next;
}
}

override function add( e : BatchElement, before=false ){
e = super.add(e,before);
if( allocated && Std.isOfType(e,HSpriteBE) )
(cast e:HSpriteBE).onAdd();
Std.downcast(e, HSpriteBE).onAdd();
return e;
}

override function delete( e : BatchElement ){
super.delete(e);
if( allocated && Std.isOfType(e,HSpriteBE) )
(cast e:HSpriteBE).onRemove();
Std.downcast(e, HSpriteBE).onRemove();
}

}

0 comments on commit 53f80ad

Please sign in to comment.