core

## Class SpriteGroup

- java.lang.Object
- - core.SpriteGroup

-     public class SpriteGroup
      extends java.lang.Object

  Created by Diego on 18/03/14. This class encapsulates a SpriteGroup: a collection of VGDLSprite objects identified with an unique id. All sprites in the SpriteGroup are of the same type.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpriteGroup(int itype)` Creates a new SpriteGroup, specifying the type of sprites this will hold.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAllSprites(java.util.Collection<VGDLSprite> spritesToAdd)` Adds a collection of sprites to this collection.
    `void` | `addSprite(int spriteId, VGDLSprite sprite)` Adds an sprite to the collection.
    `void` | `clear()` Clears the collection of sprites.
    `VGDLSprite` | `getFirstSprite()` Gets the first sprite of this collection, or null if it is empty
    `int` | `getItype()` Gets the type of this SpriteGroup.
    `java.lang.Integer[]` | `getKeys()` Gets the set of KEYs in an array.
    `VGDLSprite` | `getSprite(int spriteId)` Retrieves a sprite given its unique ID.
    `java.util.Iterator<VGDLSprite>` | `getSpriteIterator()` Gets an ordered iterator through all sprites.
    `java.util.TreeMap<java.lang.Integer,VGDLSprite>` | `getSprites()` Gets the collection of sprites, as a TreeMap [KEY => VALUE].
    `int` | `numSprites()` Gets the number of sprites in the collection.
    `void` | `removeSprite(int spriteId)` Removes an sprite indicated with its ID.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SpriteGroup

          public SpriteGroup(int itype)

      Creates a new SpriteGroup, specifying the type of sprites this will hold.
      Parameters:
        `itype` - type of sprite for the SpriteGroup.

  - ### Method Detail

    - #### addSprite

          public void addSprite(int spriteId,
                       VGDLSprite sprite)

      Adds an sprite to the collection.
      Parameters:
        `spriteId` - Unique ID of the sprite to add
        `sprite` - Sprite to add.

    - #### addAllSprites

          public void addAllSprites(java.util.Collection<VGDLSprite> spritesToAdd)

      Adds a collection of sprites to this collection.
      Parameters:
        `spritesToAdd` - Sprites to add.

    - #### getSprites

          public java.util.TreeMap<java.lang.Integer,VGDLSprite> getSprites()

      Gets the collection of sprites, as a TreeMap [KEY => VALUE].
      Returns:
        the TreeMap with the Sprites.

    - #### getKeys

          public java.lang.Integer[] getKeys()

      Gets the set of KEYs in an array. It will return null if the collection of sprites is empty.
      Returns:
        the list of the sprite keys in this collection in an array.

    - #### getSpriteIterator

          public java.util.Iterator<VGDLSprite> getSpriteIterator()

      Gets an ordered iterator through all sprites. It will return null if the collection of sprites is empty.
      Returns:
        the list of the sprites in this collection in an iterator.

    - #### removeSprite

          public void removeSprite(int spriteId)

      Removes an sprite indicated with its ID.
      Parameters:
        `spriteId` - the id of the sprite to remove.

    - #### getItype

          public int getItype()

      Gets the type of this SpriteGroup.
      Returns:
        the type of this sprite group

    - #### getSprite

          public VGDLSprite getSprite(int spriteId)

      Retrieves a sprite given its unique ID. It'll return null if the sprite is not in the collection.
      Parameters:
        `spriteId` - ID of the sprite to retrieve.
      Returns:
        the desired sprite.

    - #### clear

          public void clear()

      Clears the collection of sprites.

    - #### numSprites

          public int numSprites()

      Gets the number of sprites in the collection.
      Returns:
        number of sprites in this collection.

    - #### getFirstSprite

          public VGDLSprite getFirstSprite()

      Gets the first sprite of this collection, or null if it is empty
      Returns:
        the first sprite in this collection.