public abstract class SceneObject extends Object
Modifier and Type | Field and Description |
---|---|
protected static Point |
ORIGIN_TOP_LEFT |
Constructor and Description |
---|
SceneObject() |
Modifier and Type | Method and Description |
---|---|
boolean |
collides(SceneObject obj)
Check, if both
SceneObject s collide. |
Rectangle |
collidesBoundingBox(SceneObject obj)
Check collision with bounding box algorithm.
|
boolean |
collidesExactly(SceneObject obj,
Rectangle intersection)
Check exactly if a collision is present.
|
boolean |
consumes(SceneObject obj)
Check, if the given
SceneObject is completely covered by this
SceneObject . |
boolean |
consumesBoundingBox(SceneObject obj)
Tests overlapping with bounding box.
|
boolean |
consumesExactly(SceneObject obj)
Exactly check overlapping.
|
int |
getHeight()
The height of this
SceneObject |
Point |
getOrigin()
The origin of this
SceneObject . |
Point |
getPosition()
Get the position of this
SceneObject |
double |
getPreciseHeight()
The precise height of this
SceneObject |
double |
getPreciseWidth()
The precise width of this
SceneObject |
double |
getPreciseX()
The precise X-Coordinate of this
SceneObject |
double |
getPreciseY()
The precise Y-Coordinate of this
SceneObject |
Rectangle |
getRectangle()
Get the
Rectangle representing this object's bounds. |
RenderingOptions |
getRenderingOptions()
Get the
RenderingOptions used for painting. |
Size |
getSize()
The size of this
SceneObject |
Point |
getTopLeftPosition()
The position of this
SceneObject 's top left corner |
int |
getWidth()
The width of this
SceneObject |
int |
getX()
The X-Coordinate of this
SceneObject |
int |
getY()
The Y-Coordinate of this
SceneObject |
boolean |
isDrawBoundingBox()
Check if the bounding box of this
SceneObject is painted or not. |
protected abstract void |
paint(Graphics2D g,
long elapsedTime)
Paint this SceneObject.
|
protected void |
paintAbsoluteOnScene(Graphics2D g,
long elapsedTime)
Paint this SceneObject using absolute coordinates.
|
void |
paintOnScene(Graphics2D g,
int width,
int height,
long elapsedTime)
Paints this SceneObject and applies the actual
RenderingOptions . |
void |
paintOnScene(Graphics2D g,
long elapsedTime)
Deprecated.
Use
paintOnScene(Graphics2D, Size, long) instead |
protected void |
paintOnScene(Graphics2D g,
Point positionTopLeft,
Size size,
long elapsedTime)
Paint on scene with given size and position
|
void |
paintOnScene(Graphics2D g,
Size sceneSize,
long elapsedTime)
Paints this SceneObject and applies the actual
RenderingOptions . |
void |
setDrawBoundingBox(boolean drawBoundingBox)
Change the drawing state of the bounding box.
|
void |
setPosition(int x,
int y)
Set the position of this
SceneObject |
void |
setPosition(Point position)
Set the position of this
SceneObject |
void |
setRenderingOptions(RenderingOptions renderingOptions)
Set the
RenderingOptions for painting. |
void |
setSize(int width,
int height) |
void |
setSize(Size size)
Set the size of this
SceneObject |
void |
setTopLeftPosition(Point p)
Set the position of this
SceneObject 's top left corner |
protected static final Point ORIGIN_TOP_LEFT
protected abstract void paint(Graphics2D g, long elapsedTime)
SceneObject
it is
important, that the object is drawn in it's actual state.g
- Graphics Object for paintingelapsedTime
- Elapsed time since the last call to this method@Deprecated public void paintOnScene(Graphics2D g, long elapsedTime)
paintOnScene(Graphics2D, Size, long)
insteadRenderingOptions
.g
- Graphics Object for paintingelapsedTime
- Elapsed time since the last call to this methodpublic void paintOnScene(Graphics2D g, int width, int height, long elapsedTime)
RenderingOptions
.g
- Graphics Object for paintingelapsedTime
- Elapsed time since the last call to this methodwidth
- Scene widthheight
- scene heightpaintOnScene(Graphics2D, Size, long)
public void paintOnScene(Graphics2D g, Size sceneSize, long elapsedTime)
RenderingOptions
.g
- Graphics Object for paintingsceneSize
- Scene sizeelapsedTime
- Elapsed time since the last call to this methodpaintOnScene(Graphics2D, Size, long)
protected void paintAbsoluteOnScene(Graphics2D g, long elapsedTime)
g
- Graphics Object for paintingelapsedTime
- Elapsed time since the last call to this methodprotected void paintOnScene(Graphics2D g, Point positionTopLeft, Size size, long elapsedTime)
g
- Graphics Object for paintingpositionTopLeft
- Top left position of objectsize
- Absolute size of objectelapsedTime
- Elapsed time since the last call to this methodpublic Point getTopLeftPosition()
SceneObject
's top left cornerpublic void setTopLeftPosition(Point p)
SceneObject
's top left cornerpublic Point getPosition()
SceneObject
public int getY()
SceneObject
getPosition()
public double getPreciseY()
SceneObject
getPosition()
public int getX()
SceneObject
getPosition()
public double getPreciseX()
SceneObject
getPosition()
public void setPosition(Point position)
SceneObject
position
- The Position of this ScreenObjectpublic void setPosition(int x, int y)
SceneObject
x
- The X-Coordinate of this ScreenObjecty
- The Y-Coordinate of this ScreenObjectsetPosition(Point)
public Point getOrigin()
SceneObject
. This object's position will be
translated to it's origin. The default implementation returns
ORIGIN_TOP_LEFT
public Size getSize()
SceneObject
public int getHeight()
SceneObject
getSize()
public double getPreciseHeight()
SceneObject
getSize()
public int getWidth()
SceneObject
getSize()
public double getPreciseWidth()
SceneObject
getSize()
public void setSize(Size size)
SceneObject
size
- Size of this ScreenObjectpublic void setSize(int width, int height)
width
- Width of this ScreenObjectheight
- Height of this ScreenObjectsetSize(Size)
public boolean isDrawBoundingBox()
SceneObject
is painted or not. If
it is painted a rectangle will be drawn around the dimensions of this object.public void setDrawBoundingBox(boolean drawBoundingBox)
drawBoundingBox
- true if the bounding box should be paintedpublic RenderingOptions getRenderingOptions()
RenderingOptions
used for painting. The are applied to every
Graphics2D
object, this one is painted on.setRenderingOptions(RenderingOptions)
public void setRenderingOptions(RenderingOptions renderingOptions)
RenderingOptions
for painting.renderingOptions
- getRenderingOptions()
public boolean consumes(SceneObject obj)
SceneObject
is completely covered by this
SceneObject
.obj
- Other Object for testingpublic boolean consumesExactly(SceneObject obj)
obj
- Other object for testingSceneObject
is consumed by this objectpublic boolean consumesBoundingBox(SceneObject obj)
obj
- Other Object for testingpublic boolean collides(SceneObject obj)
SceneObject
s collide.obj
- Second SceneObjectSceneObject
s collidecollidesExactly(SceneObject, Rectangle)
,
collidesBoundingBox(SceneObject)
public boolean collidesExactly(SceneObject obj, Rectangle intersection)
collidesBoundingBox(SceneObject)
returns a non empty region. The
default implementation tests every pixel drawn by this object. If there's a
pixel set (alpha != 0) in both objects they collide. Depending on the object
there maybe a better collision handling. Feel free to override this method
for better performance.obj
- The second SceneObject
for testingintersection
- Region in which the collision may occurpublic Rectangle collidesBoundingBox(SceneObject obj)
obj
- The second SceneObject
for testingCopyright © 2017. All rights reserved.