Package cl.cromer.azaraka.sprite
Class Animation
- java.lang.Object
-
- cl.cromer.azaraka.sprite.Animation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Animation.Direction
The directions that the image can use-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
-
Fields inherited from interface cl.cromer.azaraka.Constants
AI_HEURISTIC, APPEND_LOGS, CELL_PIXELS, CHESTS, ENEMIES, ENEMY_AI, EXPORT_SCENE, FONT, FONT_SIZE, GENERATE_SCENE, GLOBAL_LOG, HORIZONTAL_CELLS, LOG_TO_FILE, OBSTACLES, PLAYER_AI, PRETTY_JSON, TITLE, VERTICAL_CELLS, VOLUME
-
-
Constructor Summary
Constructors Constructor Description Animation()
Initialize the sprite
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addImage(Animation.Direction direction, java.awt.image.BufferedImage bufferedImage)
Add an image to the animationvoid
addImage(Animation.Direction direction, java.lang.String path)
Add an image to the animationjava.lang.Object
clone()
Enable the sprite to be cloned into various cellsAnimation.Direction
getCurrentDirection()
Get the current direction that the animation is usingint
getCurrentFrame()
Get the current framejava.awt.image.BufferedImage
getFrame()
Returns the current frame in the spriteint
getFrameCount()
Get the number of frames in thevoid
getNextFrame()
Returns the next frame in the spriteint
getXOffset()
Get the offset of x for the spriteint
getYOffset()
Get the offset of y for the spritestatic java.awt.image.BufferedImage
scaleImage(java.awt.image.BufferedImage image, int width, int height)
Scale an imagevoid
setCurrentDirection(Animation.Direction currentDirection)
Change the animation to the new direction and set the current frame to 0void
setCurrentFrame(int frame)
Set which frame is to be shown in the sprite manuallyvoid
setYOffset(int yOffset)
Set the y offset manually instead of using the automatically detected value-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
Method Detail
-
scaleImage
public static java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage image, int width, int height)
Scale an image- Parameters:
image
- The image to scalewidth
- The new widthheight
- The new height- Returns:
- Returns the scaled image
-
getXOffset
public int getXOffset()
Get the offset of x for the sprite- Returns:
- Returns the x offset in pixels
-
getYOffset
public int getYOffset()
Get the offset of y for the sprite- Returns:
- Returns the y offset in pixels
-
setYOffset
public void setYOffset(int yOffset)
Set the y offset manually instead of using the automatically detected value- Parameters:
yOffset
- The new y offset
-
addImage
public void addImage(Animation.Direction direction, java.lang.String path)
Add an image to the animation- Parameters:
direction
- The direction to add the image topath
- The path to the sprite e.g. res/player/image.png
-
addImage
public void addImage(Animation.Direction direction, java.awt.image.BufferedImage bufferedImage)
Add an image to the animation- Parameters:
direction
- The direction to add the image tobufferedImage
- The path to the sprite e.g. res/player/image.png
-
getFrame
public java.awt.image.BufferedImage getFrame() throws AnimationException
Returns the current frame in the sprite- Returns:
- Returns the current frame
- Throws:
AnimationException
- Thrown when there are no images in the sprite
-
getFrameCount
public int getFrameCount() throws AnimationException
Get the number of frames in the- Returns:
- Returns the amount of frames in the sprite
- Throws:
AnimationException
- Thrown if there are no images in the animation
-
getCurrentFrame
public int getCurrentFrame() throws AnimationException
Get the current frame- Returns:
- Returns the current frame
- Throws:
AnimationException
- Thrown if there are no frame in the current animation
-
setCurrentFrame
public void setCurrentFrame(int frame) throws AnimationException
Set which frame is to be shown in the sprite manually- Parameters:
frame
- The frame to show- Throws:
AnimationException
- Thrown if the frame number does not exist
-
getNextFrame
public void getNextFrame() throws AnimationException
Returns the next frame in the sprite- Throws:
AnimationException
- Thrown when there are no images in the sprite
-
getCurrentDirection
public Animation.Direction getCurrentDirection()
Get the current direction that the animation is using- Returns:
- Returns the current direction
-
setCurrentDirection
public void setCurrentDirection(Animation.Direction currentDirection)
Change the animation to the new direction and set the current frame to 0- Parameters:
currentDirection
- The new direction
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Enable the sprite to be cloned into various cells- Overrides:
clone
in classjava.lang.Object
- Returns:
- The cloned sprite
- Throws:
java.lang.CloneNotSupportedException
- Thrown if the object does not support cloning
-
-