Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.newdawn.slick
Class SpriteSheet

    java.lang.Object
      org.newdawn.slick.Image
          org.newdawn.slick.SpriteSheet

All Implemented Interfaces:
  Renderable

    public class SpriteSheet

extends Image

A sheet of sprites that can be drawn individually

Author:
  Kevin Glass

Field Summary

Fields inherited from class org.newdawn.slick.Image
`alpha, angle, BOTTOM_LEFT, BOTTOM_RIGHT, centerX, centerY, corners, destroyed, FILTER_LINEAR, FILTER_NEAREST, GL, height, inited, inUse, name, pixelData, ref, texture, textureHeight, textureOffsetX, textureOffsetY, textureWidth, TOP_LEFT, TOP_RIGHT, width`

Constructor Summary
`SpriteSheet(Image image, int tw, int th)` Create a new sprite sheet based on a image location
`SpriteSheet(Image image, int tw, int th, int spacing)` Create a new sprite sheet based on a image location
`SpriteSheet(Image image, int tw, int th, int spacing, int margin)` Create a new sprite sheet based on a image location
`SpriteSheet(java.lang.String name, java.io.InputStream ref, int tw, int th)` Create a new sprite sheet based on a image location
`SpriteSheet(java.lang.String ref, int tw, int th)` Create a new sprite sheet based on a image location
`SpriteSheet(java.lang.String ref, int tw, int th, Color col)` Create a new sprite sheet based on a image location
`SpriteSheet(java.lang.String ref, int tw, int th, Color col, int spacing)` Create a new sprite sheet based on a image location
`SpriteSheet(java.lang.String ref, int tw, int th, int spacing)` Create a new sprite sheet based on a image location
`SpriteSheet(java.net.URL ref, int tw, int th)` Create a new sprite sheet based on a image location

Method Summary
`void` | `endUse()` End the use of this sprite sheet and release the lock.
`int` | `getHorizontalCount()` Get the number of sprites across the sheet
`Image` | `getSprite(int x, int y)` Get a sprite at a particular cell on the sprite sheet
`Image` | `getSubImage(int x, int y)` Get the sub image cached in this sprite sheet
`int` | `getVerticalCount()` Get the number of sprites down the sheet
`protected void` | `initImpl()` Hook for subclasses to perform initialisation
`void` | `renderInUse(int x, int y, int sx, int sy)` Render a sprite when this sprite sheet is in use.
`void` | `setTexture(Texture texture)` Set the texture used by this image
`void` | `startUse()` Start using this sheet.

Methods inherited from class org.newdawn.slick.Image
`bind, clampTexture, copy, destroy, draw, draw, draw, draw, draw, draw, draw, draw, draw, draw, drawCentered, drawEmbedded, drawEmbedded, drawEmbedded, drawFlash, drawFlash, drawFlash, drawSheared, drawSheared, drawWarped, ensureInverted, flushPixelData, getAlpha, getCenterOfRotationX, getCenterOfRotationY, getColor, getFilter, getFlippedCopy, getGraphics, getHeight, getName, getResourceReference, getRotation, getScaledCopy, getScaledCopy, getSubImage, getTexture, getTextureHeight, getTextureOffsetX, getTextureOffsetY, getTextureWidth, getWidth, init, isDestroyed, reinit, rotate, setAlpha, setCenterOfRotation, setColor, setColor, setFilter, setImageColor, setImageColor, setName, setRotation, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SpriteSheet

    public SpriteSheet(java.net.URL ref,
                       int tw,
                       int th)
                throws SlickException,
                       java.io.IOException

  Create a new sprite sheet based on a image location

  Parameters:
    `ref` - The URL to the image to use
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
  Throws:
    `SlickException` - Indicates a failure to read image data
    `java.io.IOException` - Indicates the URL could not be opened

### SpriteSheet

    public SpriteSheet(Image image,
                       int tw,
                       int th)

  Create a new sprite sheet based on a image location

  Parameters:
    `image` - The image to based the sheet of
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet

### SpriteSheet

    public SpriteSheet(Image image,
                       int tw,
                       int th,
                       int spacing,
                       int margin)

  Create a new sprite sheet based on a image location

  Parameters:
    `image` - The image to based the sheet of
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
    `spacing` - The spacing between tiles
    `margin` - The magrin around the tiles

### SpriteSheet

    public SpriteSheet(Image image,
                       int tw,
                       int th,
                       int spacing)

  Create a new sprite sheet based on a image location

  Parameters:
    `image` - The image to based the sheet of
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
    `spacing` - The spacing between tiles

### SpriteSheet

    public SpriteSheet(java.lang.String ref,
                       int tw,
                       int th,
                       int spacing)
                throws SlickException

  Create a new sprite sheet based on a image location

  Parameters:
    `ref` - The location of the sprite sheet to load
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
    `spacing` - The spacing between tiles
  Throws:
    `SlickException` - Indicates a failure to load the image

### SpriteSheet

    public SpriteSheet(java.lang.String ref,
                       int tw,
                       int th)
                throws SlickException

  Create a new sprite sheet based on a image location

  Parameters:
    `ref` - The location of the sprite sheet to load
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
  Throws:
    `SlickException` - Indicates a failure to load the image

### SpriteSheet

    public SpriteSheet(java.lang.String ref,
                       int tw,
                       int th,
                       Color col)
                throws SlickException

  Create a new sprite sheet based on a image location

  Parameters:
    `ref` - The location of the sprite sheet to load
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
    `col` - The colour to treat as transparent
  Throws:
    `SlickException` - Indicates a failure to load the image

### SpriteSheet

    public SpriteSheet(java.lang.String ref,
                       int tw,
                       int th,
                       Color col,
                       int spacing)
                throws SlickException

  Create a new sprite sheet based on a image location

  Parameters:
    `ref` - The location of the sprite sheet to load
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
    `col` - The colour to treat as transparent
    `spacing` - The spacing between tiles
  Throws:
    `SlickException` - Indicates a failure to load the image

### SpriteSheet

    public SpriteSheet(java.lang.String name,
                       java.io.InputStream ref,
                       int tw,
                       int th)
                throws SlickException

  Create a new sprite sheet based on a image location

  Parameters:
    `name` - The name to give to the image in the image cache
    `ref` - The stream from which we can load the image
    `tw` - The width of the tiles on the sheet
    `th` - The height of the tiles on the sheet
  Throws:
    `SlickException` - Indicates a failure to load the image

Method Detail

### initImpl

    protected void initImpl()

  Description copied from class: `Image`
  Hook for subclasses to perform initialisation

  Overrides:
    `initImpl` in class `Image`
  See Also:
    `Image.initImpl()`

### getSubImage

    public Image getSubImage(int x,
                             int y)

  Get the sub image cached in this sprite sheet

  Parameters:
    `x` - The x position in tiles of the image to get
    `y` - The y position in tiles of the image to get
  Returns:
    The subimage at that location on the sheet

### getSprite

    public Image getSprite(int x,
                           int y)

  Get a sprite at a particular cell on the sprite sheet

  Parameters:
    `x` - The x position of the cell on the sprite sheet
    `y` - The y position of the cell on the sprite sheet
  Returns:
    The single image from the sprite sheet

### getHorizontalCount

    public int getHorizontalCount()

  Get the number of sprites across the sheet

  Returns:
    The number of sprites across the sheet

### getVerticalCount

    public int getVerticalCount()

  Get the number of sprites down the sheet

  Returns:
    The number of sprite down the sheet

### renderInUse

    public void renderInUse(int x,
                            int y,
                            int sx,
                            int sy)

  Render a sprite when this sprite sheet is in use.

  Parameters:
    `x` - The x position to render the sprite at
    `y` - The y position to render the sprite at
    `sx` - The x location of the cell to render
    `sy` - The y location of the cell to render
  See Also:
    `startUse()`, `endUse()`

### endUse

    public void endUse()

  Description copied from class: `Image`
  End the use of this sprite sheet and release the lock.

  Overrides:
    `endUse` in class `Image`
  See Also:
    `Image.endUse()`

### startUse

    public void startUse()

  Description copied from class: `Image`
  Start using this sheet. This method can be used for optimal rendering of a collection of sprites from a single sprite sheet. First, startUse(). Then render each sprite by calling renderInUse(). Finally, endUse(). Between start and end there can be no rendering of other sprites since the rendering is locked for this sprite sheet.

  Overrides:
    `startUse` in class `Image`
  See Also:
    `Image.startUse()`

### setTexture

    public void setTexture(Texture texture)

  Description copied from class: `Image`
  Set the texture used by this image

  Overrides:
    `setTexture` in class `Image`
  Parameters:
    `texture` - The texture used by this image
  See Also:
    `Image.setTexture(org.newdawn.slick.opengl.Texture)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 New Dawn Software. All Rights Reserved.