com.b3dgs.lionengine.drawable.impl
Class DrawableFactory

java.lang.Object
  extended by com.b3dgs.lionengine.drawable.impl.DrawableFactory
All Implemented Interfaces:
Drawable

public final class DrawableFactory
extends java.lang.Object
implements Drawable


Field Summary
 
Fields inherited from interface com.b3dgs.lionengine.Drawable
DRAWABLE
 
Method Summary
 Animation createAnimation(int firstFrame, int lastFrame, int step, float speed, boolean reverse, boolean repeat)
          Create an animation, which can be read by an animated sprite.
 Animator createAnimator()
          Create an animation player, which we will be able to play an animation data container.
 Cursor createCursor(Screen screen, java.lang.String cursor)
          Create a cursor, which is automatically handled by the mouse.
 FontSprite createFontSprite(java.lang.String filename, java.lang.String data, int lw, int lh)
          Create a font based on an image.
 Text createText(java.lang.String filename, int size, int style)
          Create a font, which supports screen output text.
static Drawable getInstance()
           
 AnimatedSprite loadAnimatedSprite(java.awt.image.BufferedImage surface, int numberOfHorizontalFrames, int numberOfVerticalFrames)
          Create an animated sprite, giving horizontal and vertical frames (sharing the same surface).
 AnimatedSprite loadAnimatedSprite(java.lang.String filename, int numberOfHorizontalFrames, int numberOfVerticalFrames)
          Load an animated sprite from a file, giving horizontal and vertical frames.
 Image loadImage(java.awt.image.BufferedImage surface)
          Create an image from a buffered image (sharing the same surface).
 Image loadImage(java.lang.String filename)
          Load an image from a file.
 ParallaxedSprite loadParallaxedSprite(java.lang.String filename, int numberOfLines, int sx, int sy)
          Load a parallaxed sprite, for parallax effect.
 Sprite loadSprite(java.awt.image.BufferedImage surface)
          Create a sprite from a buffered image (sharing the same surface).
 Sprite loadSprite(java.lang.String filename)
          Load a sprite from a file.
 TiledSprite loadTiledSprite(java.awt.image.BufferedImage surface, int tileWidth, int tileHeight)
          Create a tiled sprite using an image reference, giving tile dimension (sharing the same surface).
 TiledSprite loadTiledSprite(java.lang.String filename, int tileWidth, int tileHeight)
          Load a tiled sprite from a file, giving tile dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Drawable getInstance()
Returns:
singleton.

loadImage

public Image loadImage(java.lang.String filename)
Description copied from interface: Drawable
Load an image from a file.

Specified by:
loadImage in interface Drawable
Parameters:
filename - file name.
Returns:
loaded image.

loadImage

public Image loadImage(java.awt.image.BufferedImage surface)
Description copied from interface: Drawable
Create an image from a buffered image (sharing the same surface). It may be usefull in case of multiple images.

Specified by:
loadImage in interface Drawable
Parameters:
surface - file name.
Returns:
loaded image.

loadSprite

public Sprite loadSprite(java.lang.String filename)
Description copied from interface: Drawable
Load a sprite from a file.

Specified by:
loadSprite in interface Drawable
Parameters:
filename - file name.
Returns:
loaded tiled sprite.

loadSprite

public Sprite loadSprite(java.awt.image.BufferedImage surface)
Description copied from interface: Drawable
Create a sprite from a buffered image (sharing the same surface). It may be usefull in case of multiple sprites.

Specified by:
loadSprite in interface Drawable
Parameters:
surface - image reference.
Returns:
loaded sprite.

loadAnimatedSprite

public AnimatedSprite loadAnimatedSprite(java.lang.String filename,
                                         int numberOfHorizontalFrames,
                                         int numberOfVerticalFrames)
Description copied from interface: Drawable
Load an animated sprite from a file, giving horizontal and vertical frames.

Specified by:
loadAnimatedSprite in interface Drawable
Parameters:
filename - file name.
numberOfHorizontalFrames - number of horizontal frames.
numberOfVerticalFrames - number of vertical frames.
Returns:
loaded animated sprite.

loadAnimatedSprite

public AnimatedSprite loadAnimatedSprite(java.awt.image.BufferedImage surface,
                                         int numberOfHorizontalFrames,
                                         int numberOfVerticalFrames)
Description copied from interface: Drawable
Create an animated sprite, giving horizontal and vertical frames (sharing the same surface). It may be usefull in case of multiple animated sprites.

Specified by:
loadAnimatedSprite in interface Drawable
Parameters:
surface - image reference.
numberOfHorizontalFrames - number of horizontal frames.
numberOfVerticalFrames - number of vertical frames.
Returns:
loaded animated sprite.

loadTiledSprite

public TiledSprite loadTiledSprite(java.lang.String filename,
                                   int tileWidth,
                                   int tileHeight)
Description copied from interface: Drawable
Load a tiled sprite from a file, giving tile dimension.

Specified by:
loadTiledSprite in interface Drawable
Parameters:
filename - file name.
tileWidth - tile width.
tileHeight - tile height.
Returns:
loaded tiled sprite.

loadTiledSprite

public TiledSprite loadTiledSprite(java.awt.image.BufferedImage surface,
                                   int tileWidth,
                                   int tileHeight)
Description copied from interface: Drawable
Create a tiled sprite using an image reference, giving tile dimension (sharing the same surface). It may be usefull in case of multiple tiled sprites.

Specified by:
loadTiledSprite in interface Drawable
Parameters:
surface - image reference.
tileWidth - tile width.
tileHeight - tile height.
Returns:
loaded tiled sprite.

loadParallaxedSprite

public ParallaxedSprite loadParallaxedSprite(java.lang.String filename,
                                             int numberOfLines,
                                             int sx,
                                             int sy)
Description copied from interface: Drawable
Load a parallaxed sprite, for parallax effect.

Specified by:
loadParallaxedSprite in interface Drawable
Parameters:
filename - file name.
numberOfLines - number of parallax lines.
sx - starting width.
sy - starting height.
Returns:
loaded parallaxed sprite.

createAnimation

public Animation createAnimation(int firstFrame,
                                 int lastFrame,
                                 int step,
                                 float speed,
                                 boolean reverse,
                                 boolean repeat)
Description copied from interface: Drawable
Create an animation, which can be read by an animated sprite. Minimum frame is 1. Note about the step: Mainly used for strategy games, where the entry has different orientations. The step represents the number of frames per orientation for this animation.

Specified by:
createAnimation in interface Drawable
Parameters:
firstFrame - first frame index to play.
lastFrame - last frame index to play.
step - animation step number.
speed - animation playing speed.
reverse - true to reverse play (play from first to last, and last to first).
repeat - repeat state (loop play).
Returns:
created animation.

createAnimator

public Animator createAnimator()
Description copied from interface: Drawable
Create an animation player, which we will be able to play an animation data container.

Specified by:
createAnimator in interface Drawable
Returns:
created animation player.

createText

public Text createText(java.lang.String filename,
                       int size,
                       int style)
Description copied from interface: Drawable
Create a font, which supports screen output text.

Specified by:
createText in interface Drawable
Parameters:
filename - font name.
size - font size (in px).
style - font style (NORMAL, BOLD, ITALIC).
Returns:
created text.
See Also:
Font.DIALOG, Font.MONOSPACED, Font.SANS_SERIF, Font.SERIF, Text.NORMAL, Text.BOLD, Text.ITALIC

createFontSprite

public FontSprite createFontSprite(java.lang.String filename,
                                   java.lang.String data,
                                   int lw,
                                   int lh)
Description copied from interface: Drawable
Create a font based on an image.

Specified by:
createFontSprite in interface Drawable
Parameters:
filename - font surface filename.
data - font data filename.
lw - font image letter width.
lh - font image letter height.
Returns:
created font sprite.

createCursor

public Cursor createCursor(Screen screen,
                           java.lang.String cursor)
Description copied from interface: Drawable
Create a cursor, which is automatically handled by the mouse.

Specified by:
createCursor in interface Drawable
Parameters:
screen - screen reference.
cursor - cursor image name.
Returns:
created cursor.