|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.haphazard.gui.engine.Sprite
A class for handling animated or non-animated graphics Note: Sprite = a non-moving object (though it can be moved, now) that may be animated. xPos and yPos defines its position, i.e., the upper-left corner starting position, in isometric coordinates
Field Summary | |
java.lang.String |
mLink
A String denoting where this Sprite were loaded from |
Constructor Summary | |
Sprite(java.lang.String name,
boolean displayLoop)
This constructor can be used for XML-parsing. |
|
Sprite(java.lang.String name,
Frame[] frames,
boolean displayLoop)
The constructor that inilize the variables. |
Method Summary | |
java.lang.Object |
clone()
|
Sprite |
combine(Sprite spriteToBeInFront,
java.lang.String theNameOfTheNewSprite)
Combine this sprite with a new sprite. |
Sprite |
flipBoth()
Creates a new sprite that is flipped both ways |
Sprite |
flipHorizontally()
Creates a new sprite that is horizontally flipped |
Sprite |
flipVertically()
Creates a new sprite that is vertically flipped |
java.awt.Rectangle |
getBoundingBox(java.awt.Point middleTileCoordinate)
Return the bounding box on the screen of this image. |
java.util.Vector |
getFrames()
Return the array of frames that this Sprite has. |
java.lang.String |
getMirrorName(java.lang.String alignment)
Gets this images mirror name, or null if it has none |
java.lang.String |
getName()
Gets this sprites name |
boolean |
hasMirror()
Checks if this sprite has a mirror image |
boolean |
isAnimated()
A check to se if this sprites contains a animation ( = more than one frame ) |
boolean |
isAnimationTerminated()
Checks if the animation is finished (i.e. the sprited displays the last frame) |
boolean |
isLoop()
|
boolean |
isMirror()
Checks if this sprite is a generated mirror image If it is generated the sprite will not generate any XML info on save |
boolean |
isMirror(boolean isMirror)
Sets if this sprite is a generated mirror image |
void |
optimize()
Optimizes this Sprite for better graphics performance |
boolean |
paintComponent(java.awt.Graphics2D g,
java.awt.Point middleTileCoordinate)
Paint this Sprite on the screen-coordinate |
void |
resetAnimation()
Resets this sprites animation. |
void |
setFrames(java.util.Vector frames)
This is used in the XML-parser |
void |
setLoop(boolean loop)
Sets if this animation loops or not |
void |
setMirror(java.lang.String mirrorDirection,
java.lang.String name)
Sets that this sprite has a mirror The actual mirror is generated when loading the sprite, if a mirror sprite is needed right away also use GlobalImageUtilities.flipHorizontally and GlobalImageUtilities.flipVertically |
void |
setName(java.lang.String name)
Sets this sprites name; |
java.lang.String |
toString()
Transforms this sprite into a string notation |
java.lang.String |
toXML(int indent)
Transforms this object into XML-notation |
void |
update()
Calculate what frame should be displayed |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public java.lang.String mLink
Constructor Detail |
public Sprite(java.lang.String name, Frame[] frames, boolean displayLoop)
name
- The name of the spriteframes
- a array of FramesdisplayLoop
- a boolean that sets if this sprite-animation should loop of it should stop when all the frames have been displayedpublic Sprite(java.lang.String name, boolean displayLoop)
name
- the name of the sprite. This is used as a hash-key in DynamicGraphicalObjectdisplayLoop
- if this Sprite-animation should be a loopMethod Detail |
public void setFrames(java.util.Vector frames)
frames
- the Frames-array that this Sprite containspublic void setLoop(boolean loop)
loop
- True if it should looppublic boolean isLoop()
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the new namepublic java.util.Vector getFrames()
public java.awt.Rectangle getBoundingBox(java.awt.Point middleTileCoordinate)
middleTileCoordinate
- The middle coordinate of the tile the sprite is residing on
public boolean hasMirror()
public java.lang.String getMirrorName(java.lang.String alignment)
alignment
- The alignment of the mirror (vertical, horizontal or both)
public void setMirror(java.lang.String mirrorDirection, java.lang.String name)
mirrorDirection
- "both" if mirror in both directionsname
- The name of the mirror imagepublic boolean isMirror(boolean isMirror)
isMirror
- This sprite is generated and should not be saved
public boolean isMirror()
public Sprite flipVertically()
public Sprite flipHorizontally()
public Sprite flipBoth()
public Sprite combine(Sprite spriteToBeInFront, java.lang.String theNameOfTheNewSprite)
spriteToBeInFront
- the sprite that should be in front.theNameOfTheNewSprite
- the new name of the sprite.
public void optimize()
public boolean paintComponent(java.awt.Graphics2D g, java.awt.Point middleTileCoordinate)
middleTileCoordinate
- The middle coordinate of the tile the Sprite is residing ong
- the Graphics where to be drawn
public void update()
public boolean isAnimationTerminated()
public boolean isAnimated()
public void resetAnimation()
public java.lang.String toXML(int indent)
indent
- The level of indentation to use
public java.lang.String toString()
public java.lang.Object clone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |