com.b3dgs.lionengine.drawable
Interface Sprite

All Superinterfaces:
Image, Renderable
All Known Subinterfaces:
AnimatedSprite, FontSprite, TiledSprite

public interface Sprite
extends Image

Sprites works like images, but it supports modifications, such as scaling and filtering. Sprites are recommended for dynamic uses, such as menus or backgrounds elements (which are not statics).


Method Summary
 void filter(Filter filter)
          Apply a filter to the sprite.
 void flipHorizontal()
          Flip the sprite horizontaly.
 void flipVertical()
          Flip the sprite verticaly.
 int getHeightOriginal()
          Get the current sprite height (its current size, after scaling operation).
 java.awt.image.BufferedImage getSurface()
          Get the sprite surface, represented by a BufferedImage.
 int getWidthOriginal()
          Get the current sprite width (its current size, after scaling operation).
 Sprite instanciate()
          Get instancied version of current sprite (shares the same surface).
 void load(boolean alpha)
          Load surface and prepare it to be displayed.
 void rotate(int angle)
          Rotate the sprite with the specified angle.
 void scale(int percent)
          Method used for sprite scaling, in order to modify its size.
 void setAlpha(int alpha)
          Set alpha value [0-255].
 void setTransparency(java.awt.Color mask)
          Set transparency color.
 void stretch(int percentWidth, int percentHeight)
          Works as scale, but using differents width and height factor.
 
Methods inherited from interface com.b3dgs.lionengine.drawable.Renderable
getHeight, getWidth, render
 

Method Detail

load

void load(boolean alpha)
Load surface and prepare it to be displayed.

Parameters:
alpha - true to enable alpha.

scale

void scale(int percent)
Method used for sprite scaling, in order to modify its size. Normal factor is equal to 100, so 200 will scale it twice bigger, whereas 50 will scale half its size.

Parameters:
percent - value for scaling.

stretch

void stretch(int percentWidth,
             int percentHeight)
Works as scale, but using differents width and height factor. Using differents value, the ratio won't be kept, and the sprite will be different !

Parameters:
percentWidth - percent value for scaling width.
percentHeight - percent value for scaling height.

rotate

void rotate(int angle)
Rotate the sprite with the specified angle.

Parameters:
angle - rotation angle.

flipHorizontal

void flipHorizontal()
Flip the sprite horizontaly.


flipVertical

void flipVertical()
Flip the sprite verticaly.


filter

void filter(Filter filter)
Apply a filter to the sprite.

Parameters:
filter - filter to use.

setTransparency

void setTransparency(java.awt.Color mask)
Set transparency color.

Parameters:
mask - color mask.

setAlpha

void setAlpha(int alpha)
Set alpha value [0-255].

Parameters:
alpha - alpha value.

getWidthOriginal

int getWidthOriginal()
Get the current sprite width (its current size, after scaling operation).

Returns:
sprite width size as integer.

getHeightOriginal

int getHeightOriginal()
Get the current sprite height (its current size, after scaling operation).

Returns:
sprite height size as integer.

getSurface

java.awt.image.BufferedImage getSurface()
Get the sprite surface, represented by a BufferedImage.

Specified by:
getSurface in interface Image
Returns:
BufferedImage reference representing the sprite.

instanciate

Sprite instanciate()
Get instancied version of current sprite (shares the same surface).

Specified by:
instanciate in interface Image
Returns:
cloned sprite.