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

## com.huguesjohnson.tiamat.graphics
Class Sprite

    java.lang.Object
      com.huguesjohnson.tiamat.graphics.Sprite

All Implemented Interfaces:
  Drawable, Storable

public class Sprite
extends java.lang.Object
implements Drawable, Storable

class Sprite - animated sprite

Author:
  Hugues Johnson

Field Summary
`static boolean` | `DEFAULT_MOVABLE`
`static int` | `DIRECTION_DOWN`
`static int` | `DIRECTION_LEFT`
`static int` | `DIRECTION_RIGHT`
`static int` | `DIRECTION_UP`
`static int` | `MAX_DIRECTION`

Constructor Summary
`Sprite(int direction, int x, int y, java.lang.String absoluteDir, java.lang.String[][] imagePaths, java.awt.Component canvas)`

Method Summary
`void` | `draw()` draw the sprite at its current (x,y) location
`void` | `draw(int x, int y)` draw the sprite at the location specified by (x,y)
`void` | `draw(int x1, int y1, int x2, int y2)` draw the sprite to fill the area specified by rectangle (x1,y1)-(x2,y2), this is completely untested and not really useful
`java.awt.Component` | `getCanvas()`
`java.awt.image.BufferedImage` | `getCurrentImage()`
`int` | `getDirection()`
`Sprite` | `getFollower()`
`java.awt.image.BufferedImage` | `getImage(int direction, int step)`
`java.lang.String[][]` | `getImagePaths()`
`java.lang.String[][]` | `getImagePathsAbsolute()`
`boolean` | `getIsMoving()`
`boolean` | `getMovable()`
`int` | `getStepIndex()`
`int` | `getX()`
`int` | `getY()`
`boolean` | `importImageData(java.lang.String[][] imagePaths)` import image data, return success
`void` | `move(int direction)` moves the sprite in the specified direction
`void` | `onDeserialize(Formatter formatter, java.lang.String absoluteDir)` The onDeserialize event should be fired after an object is de-serialized.
`void` | `setAbsoluteDir(java.lang.String absoluteDir)`
`void` | `setCanvas(java.awt.Component canvas)`
`void` | `setDirection(int direction)`
`void` | `setFollower(Sprite sprite)`
`void` | `setImage(int direction, int step, java.lang.String imagePath)`
`void` | `setIsMoving(boolean isMoving)`
`void` | `setMovable(boolean movable)`
`void` | `setStepIndex(int stepIndex)`
`void` | `setX(int x)`
`void` | `setY(int y)`
`java.lang.String` | `toString()` return a string representation of the object

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

Field Detail

### DIRECTION_UP

    public static final int DIRECTION_UP

See Also:
  Constant Field Values

### DIRECTION_DOWN

    public static final int DIRECTION_DOWN

See Also:
  Constant Field Values

### DIRECTION_LEFT

    public static final int DIRECTION_LEFT

See Also:
  Constant Field Values

### DIRECTION_RIGHT

    public static final int DIRECTION_RIGHT

See Also:
  Constant Field Values

### MAX_DIRECTION

    public static final int MAX_DIRECTION

See Also:
  Constant Field Values

### DEFAULT_MOVABLE

    public static final boolean DEFAULT_MOVABLE

See Also:
  Constant Field Values

Constructor Detail

### Sprite

    public Sprite(int direction,
                  int x,
                  int y,
                  java.lang.String absoluteDir,
                  java.lang.String[][] imagePaths,
                  java.awt.Component canvas)

Method Detail

### getDirection

    public int getDirection()

### setDirection

    public void setDirection(int direction)

### getStepIndex

    public int getStepIndex()

### setStepIndex

    public void setStepIndex(int stepIndex)

### getX

    public int getX()

### setX

    public void setX(int x)

### getY

    public int getY()

### setY

    public void setY(int y)

### getMovable

    public boolean getMovable()

### setMovable

    public void setMovable(boolean movable)

### getImagePaths

    public java.lang.String[][] getImagePaths()

### getImagePathsAbsolute

    public java.lang.String[][] getImagePathsAbsolute()

### getCurrentImage

    public java.awt.image.BufferedImage getCurrentImage()

### getImage

    public java.awt.image.BufferedImage getImage(int direction,
                                                 int step)

### setImage

    public void setImage(int direction,
                         int step,
                         java.lang.String imagePath)

### setAbsoluteDir

    public void setAbsoluteDir(java.lang.String absoluteDir)

### getFollower

    public Sprite getFollower()

### setFollower

    public void setFollower(Sprite sprite)

### getCanvas

    public java.awt.Component getCanvas()

### setCanvas

    public void setCanvas(java.awt.Component canvas)

### setIsMoving

    public void setIsMoving(boolean isMoving)

### getIsMoving

    public boolean getIsMoving()

### importImageData

    public boolean importImageData(java.lang.String[][] imagePaths)

  import image data, return success

### move

    public void move(int direction)

  moves the sprite in the specified direction

### draw

    public void draw()

  draw the sprite at its current (x,y) location

  Specified by:
    `draw` in interface `Drawable`

### draw

    public void draw(int x,
                     int y)

  draw the sprite at the location specified by (x,y)

  Specified by:
    `draw` in interface `Drawable`

### draw

    public void draw(int x1,
                     int y1,
                     int x2,
                     int y2)

  draw the sprite to fill the area specified by rectangle (x1,y1)-(x2,y2), this is completely untested and not really useful

  Specified by:
    `draw` in interface `Drawable`

### toString

    public java.lang.String toString()

  return a string representation of the object

### onDeserialize

    public void onDeserialize(Formatter formatter,
                              java.lang.String absoluteDir)

  The onDeserialize event should be fired after an object is de-serialized. This allows objects to load transient members, set their working directory, and load Storable members if needed.

  Specified by:
    `onDeserialize` in interface `Storable`
  Parameters:
    `formatter` - the formatter to use to load any storable members
    `absoluteDir` - the working directory since all paths stored in the object should be relative

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