Class SpriteSheet

  • Direct Known Subclasses:
    VirtualSpriteSheet

    public class SpriteSheet
    extends java.lang.Object
    Image that contains the graphics for multiple sprites by including them as named regions witin the image.
    • Constructor Summary

      Constructors 
      Constructor Description
      SpriteSheet​(Image image)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      Image get​(java.lang.String name)
      Returns the image for the marked region with the specified name.
      java.util.List<Image> get​(java.lang.String firstRegionName, java.lang.String secondRegionName, java.lang.String... rest)
      Returns a sequence of images that correspond to names regions.
      Image getImage()
      Deprecated.
      Rect getRegion​(java.lang.String name)  
      java.util.Set<java.lang.String> getRegionNames()  
      protected boolean isValidRegion​(Rect region)  
      Image markRegion​(java.lang.String name, Rect region)
      Marks a region within the sprite sheet and returns the corresponding sun-image.
      • Methods inherited from class java.lang.Object

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

      • SpriteSheet

        public SpriteSheet​(Image image)
    • Method Detail

      • markRegion

        public Image markRegion​(java.lang.String name,
                                Rect region)
        Marks a region within the sprite sheet and returns the corresponding sun-image. The sub-image can also be retrieved at a later time using get(String).
        Throws:
        java.lang.IllegalArgumentException - if the region does not fit within the sprite sheet image, or if a region with the same name already exists.
      • isValidRegion

        protected boolean isValidRegion​(Rect region)
      • get

        public Image get​(java.lang.String name)
        Returns the image for the marked region with the specified name.
        Throws:
        java.lang.IllegalArgumentException - if no such region has been marked.
      • get

        public java.util.List<Image> get​(java.lang.String firstRegionName,
                                         java.lang.String secondRegionName,
                                         java.lang.String... rest)
        Returns a sequence of images that correspond to names regions.
        Throws:
        java.lang.IllegalArgumentException - if no such region has been marked.
      • getRegion

        public Rect getRegion​(java.lang.String name)
      • getRegionNames

        public java.util.Set<java.lang.String> getRegionNames()
      • getImage

        @Deprecated
        public Image getImage()
        Deprecated.