public class DirectionAnimatedSprite extends AnimatedSprite
Sprite.BoundaryPolicy
Modifier and Type | Field and Description |
---|---|
protected Direction |
currentDirection
Direction the sprite is pointing at.
|
protected java.util.Map<Direction,AnimatedImage> |
movementAnimations
Images for the different directions.
|
protected java.util.Map<Direction,AnimatedImage> |
noMovementAnimations
Images for the different directions.
|
animatedImage, invisibleAfterFrames
Constructor and Description |
---|
DirectionAnimatedSprite(Board board,
java.awt.Point startPoint,
Sprite.BoundaryPolicy policy,
AnimatedImage noDirection,
AnimatedImage north,
AnimatedImage east,
AnimatedImage south,
AnimatedImage west)
Create a new sprite.
|
DirectionAnimatedSprite(Board board,
java.awt.Point startPoint,
Sprite.BoundaryPolicy policy,
AnimatedImage noDirection,
AnimatedImage north,
AnimatedImage east,
AnimatedImage south,
AnimatedImage west,
AnimatedImage noMovementNorth,
AnimatedImage noMovementEast,
AnimatedImage noMovementSouth,
AnimatedImage noMovementWest)
Create a new sprite.
|
DirectionAnimatedSprite(Board board,
java.awt.Point startPoint,
Sprite.BoundaryPolicy policy,
AnimatedImage noDirection,
AnimatedImage north,
AnimatedImage northeast,
AnimatedImage east,
AnimatedImage southeast,
AnimatedImage south,
AnimatedImage southwest,
AnimatedImage west,
AnimatedImage northwest,
AnimatedImage noMovementNorth,
AnimatedImage noMovementNortheast,
AnimatedImage noMovementEast,
AnimatedImage noMovementSoutheast,
AnimatedImage noMovementSouth,
AnimatedImage noMovementWest,
AnimatedImage noMovementSouthwest,
AnimatedImage noMovementNorthwest)
Create a new sprite.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics g,
java.awt.image.ImageObserver observer)
Draw the sprite.
|
void |
setAllMovementAnimations(AnimatedImage animation)
Replaces the animation for all directions with the same one.
|
void |
setAllNoMovementAnimations(AnimatedImage animation)
Replaces the animation for all directions with the same one.
|
void |
setMovementAnimation(Direction direction,
AnimatedImage animation)
Sets the animation for the given direction in case of movement.
|
void |
setNoMovementAnimation(Direction direction,
AnimatedImage animation)
Sets the animation for the given direction in case of no movement.
|
setImages, setInvisibleAfterFrames
absoluteBorder, draw, ensureBoundaryPolicy, getDimension, getHeight, getPosition, getVelocity, getWidth, intersects, intersects, intersects, intersects, intersects, isActive, isVisible, keyPressed, keyReleased, keyTyped, loadPolygonFromFile, mouseClicked, mouseClicked, mouseEntered, mouseExited, mousePressed, mousePressed, mouseReleased, move, move, setActive, setBorder, setBounds, setPosition, setVelocity, setVisible, stop
protected Direction currentDirection
protected java.util.Map<Direction,AnimatedImage> movementAnimations
protected java.util.Map<Direction,AnimatedImage> noMovementAnimations
public DirectionAnimatedSprite(Board board, java.awt.Point startPoint, Sprite.BoundaryPolicy policy, AnimatedImage noDirection, AnimatedImage north, AnimatedImage east, AnimatedImage south, AnimatedImage west)
board
- our boardstartPoint
- position of spritepolicy
- policy used when sprite reachesnoDirection
- animation for no directionnorth
- animation for movement northeast
- animation for movement to the eastsouth
- animation for movement southwest
- animation for movement to the westpublic DirectionAnimatedSprite(Board board, java.awt.Point startPoint, Sprite.BoundaryPolicy policy, AnimatedImage noDirection, AnimatedImage north, AnimatedImage east, AnimatedImage south, AnimatedImage west, AnimatedImage noMovementNorth, AnimatedImage noMovementEast, AnimatedImage noMovementSouth, AnimatedImage noMovementWest)
board
- our boardstartPoint
- position of spritepolicy
- policy used when sprite reachesnoDirection
- animation for no directionnorth
- animation for movement northeast
- animation for movement to the eastsouth
- animation for movement southwest
- animation for movement to the westnoMovementNorth
- animation for non-moving sprite,
facing to the northnoMovementEast
- animation for non-moving sprite,
facing to the eastnoMovementSouth
- animation for non-moving sprite,
facing to the southnoMovementWest
- animation for non-moving sprite,
facing to the westpublic DirectionAnimatedSprite(Board board, java.awt.Point startPoint, Sprite.BoundaryPolicy policy, AnimatedImage noDirection, AnimatedImage north, AnimatedImage northeast, AnimatedImage east, AnimatedImage southeast, AnimatedImage south, AnimatedImage southwest, AnimatedImage west, AnimatedImage northwest, AnimatedImage noMovementNorth, AnimatedImage noMovementNortheast, AnimatedImage noMovementEast, AnimatedImage noMovementSoutheast, AnimatedImage noMovementSouth, AnimatedImage noMovementWest, AnimatedImage noMovementSouthwest, AnimatedImage noMovementNorthwest)
board
- our boardstartPoint
- position of spritepolicy
- policy used when sprite reachesnoDirection
- animation for no directionnorth
- animation for movement northnortheast
- animation for movement to the northeasteast
- animation for movement to the eastsoutheast
- animation for movement to the southeastsouth
- animation for movement southsouthwest
- animation for movement to the southwestwest
- animation for movement to the westnorthwest
- animation for movement to the northwestnoMovementNorth
- animation for non-moving sprite,
facing to the northnoMovementNortheast
- animation for non-moving sprite,
facing to the northeastnoMovementEast
- animation for non-moving sprite,
facing to the eastnoMovementSoutheast
- animation for non-moving sprite,
facing to the southeastnoMovementSouth
- animation for non-moving sprite,
facing to the southnoMovementWest
- animation for non-moving sprite,
facing to the westnoMovementSouthwest
- animation for non-moving sprite,
facing to the southwestnoMovementNorthwest
- animation for non-moving sprite,
facing to the northwestpublic void draw(java.awt.Graphics g, java.awt.image.ImageObserver observer)
Sprite
draw
in class AnimatedSprite
g
- graphics contextobserver
- image observerSprite.draw(Graphics, ImageObserver)
public void setAllMovementAnimations(AnimatedImage animation)
animation
- the animation to be setpublic void setAllNoMovementAnimations(AnimatedImage animation)
animation
- the animation to be setpublic final void setMovementAnimation(Direction direction, AnimatedImage animation)
direction
- the directionanimation
- the animation. If set to null
it will be ignoredpublic final void setNoMovementAnimation(Direction direction, AnimatedImage animation)
direction
- the directionanimation
- the animation