Module | Rubygame::Sprites::DepthSortGroup
In: | lib/rubygame/sprite.rb

DepthSortGroup is a mix-in module that extends Group to sort its sprites by their @depth attribute, so that sprites with low depths will appear on top of sprites with higher depths. A sprite‘s depth can be any Numeric, or nil (which will be counted as 0).

If two sprites have exactly the same depth, there is no guarantee about which one will be drawn on top of the other. (But, whichever one is on top will stay on top, at least until the group is re-sorted.)

If a sprite‘s depth changes after it has been added to the group, you must use the sort_sprites method for the change to have any effect.

### Methods

<< push sort_sprites

### Public Instance methods

<<(sprite)

Add a single sprite to the group. For efficiency reasons, this method doesn‘t re-sort sprites afterwards. You should use sort_sprites after you‘re done adding sprites. Or, better yet, just use push.

push(*sprites)

Add multiple sprites to the group, then re-sort all sprites.

sort_sprites()

Sort sprites by depth, in descending order, so that sprites with low depths will be drawn on top of sprites with high depths.

If a sprite has a depth of nil, it is sorted as if its depth were 0 (zero).

[Validate]