public interface Sprite extends Image
Sprites work like images, but support modifications, such as scaling and filtering. They are recommended for dynamic uses, such as menus, entities or backgrounds elements (which are not statics).
For each modifications (scale, flip, rotate, filter...), the original surface is kept. So rotate(1)
followed by rotate(-1)
will give the same sprite as before.
There are two steps for the initialization:
Image.load()
(this function will load the surface)A non loaded sprite can be displayed (nothing will be displayed), but the sprite information are available (size). However, sprite manipulation will throw an exception as the surface is not available.
Example:
// Load final Sprite sprite = Drawable.loadSprite(Medias.create("sprite.png")); sprite.load(false); sprite.setPosition(64, 280); // Render sprite.render(g);
Modifier and Type | Method and Description |
---|---|
void |
filter(Filter filter)
Apply a filter to the sprite.
|
Mirror |
getMirror()
Return the current mirror state used.
|
void |
rotate(int angle)
Rotate the sprite with the specified angle in degree.
|
void |
setAlpha(int alpha)
Set alpha value.
|
void |
setFade(int alpha,
int fade)
Set fade value.
|
void |
setMirror(Mirror mirror)
Set the mirror state.
|
void |
setTransparency(ColorRgba mask)
Set transparency color mask.
|
void |
stretch(double percentWidth,
double percentHeight)
Stretch and resize the image to a different percent.
|
getSurface, load, prepare, setLocation, setLocation, setOrigin
getX, getY
render
void stretch(double percentWidth, double percentHeight)
percentWidth
- The percent value for scaling width (strictly positive).percentHeight
- The percent value for scaling height (strictly positive).LionEngineException
- If arguments are invalid.void rotate(int angle)
angle
- The rotation angle in degree [0 - 359][
.void filter(Filter filter)
filter
- The filter to use.LionEngineException
- If the filter is not supported.void setTransparency(ColorRgba mask)
mask
- The color mask.void setAlpha(int alpha)
alpha
- The alpha value [0 - 255]
.LionEngineException
- If argument is invalid.void setFade(int alpha, int fade)
alpha
- The alpha value [0 - 255]
.fade
- The fade value [0 - 255]
.void setMirror(Mirror mirror)
mirror
- Set the mirror type to use (must not be null
).LionEngineException
- If invalid mirror type.Mirror getMirror()
Copyright © 2016 Byron 3D Games Studio. All rights reserved.