SortYSpritesSecondary

<- SpriteManager

Introduction

The SortYSpritesSecondary performs a sort on all ordered Sprites so that sprites with a larger Y are drawn first. The sorting based off of Y is only done on Sprites which have the same Z value. Therefore, Z takes first priority, then Sprites with the same Z will be sorted so Sprites at the bottom of the screen (smaller Y values) will be drawn last (on top). If you desire to sort the Sprites by their Y to control drawing order, it is usually better to assign FlatRedBall.SpriteManager.OrderedSortType so that the ordered sort type doesn't conflict with the manual Y-based sorting.

Code Example - Manually Calling SortYSpritesSecondary

The SortYSpritesSecondary method can be called manually. Note that this is not needed if you have set the OrderedSortType. To use SortYSpritesSecondary manually, call the method every frame at the end of Update. Add the following code at the end of your Update call (or your Screen's Activity method):

SpriteManager.SortYSpritesSecondary();

Last updated