public class DrawableSpaceLayer extends java.lang.Object implements SpaceLayer
A DrawableSpaceLayer is a type of SpaceLayer that displays a Drawable, optionally repeated horizontally and/or vertically across the rendering region. It can also be configured to shift its Drawable relative to the position of the camera to simulate parallax.
Drawable
Constructor and Description |
---|
DrawableSpaceLayer(Drawable drawable,
int repeatX,
int repeatY,
long parallaxX,
long parallaxY,
long parallaxOriginX,
long parallaxOriginY)
Constructs a DrawableSpaceLayer.
|
Modifier and Type | Method and Description |
---|---|
Drawable |
getDrawable()
Returns the Drawable that this DrawableSpaceLayer displays.
|
long |
getParallaxOriginX()
Returns this DrawableSpaceLayer's horizontal parallax origin.
|
long |
getParallaxOriginY()
Returns this DrawableSpaceLayer's vertical parallax origin.
|
long |
getParallaxX()
Returns this DrawableSpaceLayer's horizontal parallax.
|
long |
getParallaxY()
Returns this DrawableSpaceLayer's vertical parallax.
|
int |
getRepeatX()
Returns this DrawableSpaceLayer's horizontal repetition spacing.
|
int |
getRepeatY()
Returns this DrawableSpaceLayer's vertical repetition spacing.
|
void |
renderActions(Graphics g,
long cx,
long cy,
int x,
int y,
int x1,
int y1,
int x2,
int y2)
Actions for this SpaceLayer to take to render its visuals through a
Viewport's camera.
|
void |
setDrawable(Drawable drawable)
Sets the Drawable that this DrawableSpaceLayer displays to the specified
Drawable.
|
void |
setParallaxOriginX(long parallaxOriginX)
Sets this DrawableSpaceLayer's horizontal parallax origin to the
specified value.
|
void |
setParallaxOriginY(long parallaxOriginY)
Sets this DrawableSpaceLayer's vertical parallax origin to the specified
value.
|
void |
setParallaxX(long parallaxX)
Sets this DrawableSpaceLayer's horizontal parallax to the specified
value.
|
void |
setParallaxY(long parallaxY)
Sets this DrawableSpaceLayer's vertical parallax to the specified value.
|
void |
setRepeatX(int repeatX)
Sets this DrawableSpaceLayer's horizontal repetition spacing to the
specified value.
|
void |
setRepeatY(int repeatY)
Sets this DrawableSpaceLayer's vertical repetition spacing to the
specified value.
|
public DrawableSpaceLayer(Drawable drawable, int repeatX, int repeatY, long parallaxX, long parallaxY, long parallaxOriginX, long parallaxOriginY)
drawable
- The Drawable that this DrawableSpaceLayer displaysrepeatX
- The distance in pixels between horizontal repetitions of
the Drawable. If this is 0 or negative, the Drawable will not repeat
horizontally.repeatY
- The distance in pixels between vertical repetitions of
the Drawable. If this is 0 or negative, the Drawable will not repeat
vertically.parallaxX
- The number of pixels (in fracunit scale) that the
Drawable moves left for every one fracunit that the camera moves
right, and vice versa. Values between 0 and 1 are appropriate for
backgrounds, and values of at least 1 are appropriate for foregrounds. A
value of 0 will make the Drawable horizontally stationary, and a value of
1 will make it match the SpaceObject layer. Negative values will make the
Drawable look like it is across from the SpaceObject layer on the inside
of a horizontally curved surface.parallaxY
- The number of pixels (in fracunit scale) that the
Drawable moves up for every one fracunit that the camera moves
down, and vice versa. Values between 0 and 1 are appropriate for
backgrounds, and values of at least 1 are appropriate for foregrounds. A
value of 0 will make the Drawable vertically stationary, and a value of
1 will make it match the SpaceObject layer. Negative values will make the
Drawable look like it is across from the SpaceObject layer on the inside
of a vertically curved surface.parallaxOriginX
- The x position in the SpaceState's space where the
Drawable's origin x-coordinate aligns with the x position of the camera
on the rendering region. If parallaxX is 0, the above description is true
of any x position, and this value is meaningless.parallaxOriginY
- The y position in the SpaceState's space where the
Drawable's origin y-coordinate aligns with the y position of the camera
on the rendering region. If parallaxY is 0, the above description is true
of any y position, and this value is meaningless.public final Drawable getDrawable()
public final void setDrawable(Drawable drawable)
drawable
- This DrawableSpaceLayer's new displayed Drawablepublic final int getRepeatX()
public final void setRepeatX(int repeatX)
repeatX
- This DrawableSpaceLayer's new horizontal repetition
spacingpublic final int getRepeatY()
public final void setRepeatY(int repeatY)
repeatY
- This DrawableSpaceLayer's new vertical repetition spacingpublic long getParallaxX()
public void setParallaxX(long parallaxX)
parallaxX
- This DrawableSpaceLayer's new horizontal parallaxpublic long getParallaxY()
public void setParallaxY(long parallaxY)
parallaxY
- This DrawableSpaceLayer's new vertical parallaxpublic long getParallaxOriginX()
public void setParallaxOriginX(long parallaxOriginX)
parallaxOriginX
- This DrawableSpaceLayer's new horizontal parallax
originpublic long getParallaxOriginY()
public void setParallaxOriginY(long parallaxOriginY)
parallaxOriginY
- This DrawableSpaceLayer's new vertical parallax
originpublic void renderActions(Graphics g, long cx, long cy, int x, int y, int x1, int y1, int x2, int y2)
SpaceLayer
renderActions
in interface SpaceLayer
g
- The Graphics context to which this SpaceLayer is rendering its
visuals this framecx
- The camera's center x-coordinatecy
- The camera's center y-coordinatex
- The x-coordinate in pixels on the Graphics context that
corresponds to the camera's center x-coordinatey
- The y-coordinate in pixels on the Graphics context that
corresponds to the camera's center y-coordinatex1
- The x-coordinate in pixels of the Viewport's left edge on the
Graphics contexty1
- The y-coordinate in pixels of the Viewport's top edge on the
Graphics contextx2
- The x-coordinate in pixels of the Viewport's right edge on the
Graphics contexty2
- The y-coordinate in pixels of the Viewport's bottom edge on the
Graphics context