java.lang.Object
org.openpatch.scratch.extensions.sorting.Sorting

public class Sorting extends Object
Decides the order in which the sprites of a stage are drawn.

Reached through stage.getSorting():


 this.getSorting().byY();
 
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    by(Comparator<? super Sprite> comparator)
    Draws sprites in an order of your own.
    void
    byY()
    Draws sprites that are further down the stage in front of sprites that are further up, which is what a view from above usually wants.
    Returns the order currently used.
    boolean
    Checks whether the sprites are being sorted.
    void
    off()
    Draws sprites in the order they were added, which is the default.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Sorting

      public Sorting()
  • Method Details

    • byY

      public void byY()
      Draws sprites that are further down the stage in front of sprites that are further up, which is what a view from above usually wants.
    • by

      public void by(Comparator<? super Sprite> comparator)
      Draws sprites in an order of your own.
      Parameters:
      comparator - decides which of two sprites is drawn first
    • off

      public void off()
      Draws sprites in the order they were added, which is the default.
    • isOn

      public boolean isOn()
      Checks whether the sprites are being sorted.
      Returns:
      true if an order is set
    • getComparator

      public Comparator<? super Sprite> getComparator()
      Returns the order currently used.
      Returns:
      the comparator, or null if the sprites are not sorted