T
- The type of CellGame that uses the SpaceStates that this
SpaceObject can be assigned topublic abstract class SpaceObject<T extends CellGame>
extends java.lang.Object
A SpaceObject is a physical object in a SpaceState's space. SpaceObjects may be assigned to one SpaceState each in much the same way that Thinkers are assigned to CellGameStates. A SpaceObject's assigned SpaceState will keep track of time for it and its AnimationInstances. A SpaceObject's time factor represents the average number of discrete time units the SpaceObject will experience every frame while assigned to an active SpaceState. If its own time factor is negative, a SpaceObject will use its assigned SpaceState's time factor instead. If a SpaceObject is assigned to an inactive SpaceState or none at all, time will not pass for it.
A SpaceObject inherits the position, flipped status, angle of rotation, and rectangular bounding box of a locator Hitbox that is relative to no other Hitbox. A SpaceObject may also have an overlap Hitbox that represents it for purposes of overlapping other SpaceObjects and/or a solid Hitbox that represents it for purposes of surface solidity and ThinkerObjects colliding with it. The solid Hitbox's rectangular bounding box, rather than its exact shape, is what represents the SpaceObject in Cell2D's standard collision mechanics. A SpaceObject may use a single Hitbox for more than one purpose, but a Hitbox may not be used by multiple SpaceObjects at once. All of a SpaceObject's Hitboxes other than its locator Hitbox have positions, flipped statuses, and angles of rotation that are relative to those of its locator Hitbox.
A SpaceObject has a point called a center that summarizes its location. Its center has an offset that is relative to the SpaceObject's position, flipped status, and angle of rotation. SpaceObjects' centers are the points from which their distances and angles to other SpaceObjects are measured.
A SpaceObject has a Drawable appearance that represents it as seen through a Viewport's camera, as well as an alpha (opacity) value that is normalized to be between 0 to 1 and a Filter that apply to its appearance. The use of a SpaceObject's appearance, alpha value, and Filter to represent it is a result of its default draw() method, which can be overridden. A SpaceObject will only be drawn if its locator Hitbox's rectangular bounding box intersects the Viewport's field of view. A SpaceObject's draw priority determines whether it will be drawn in front of or behind other SpaceObjects that intersect it. SpaceObjects with higher draw priorities are drawn in front of those with lower ones.
If an AnimationInstance is not already assigned to a CellGameState, it may be assigned to a SpaceObject with an integer ID in the context of that SpaceObject. Only one AnimationInstance may be assigned to a given SpaceObject with a given ID at once. A SpaceObject will automatically set its assigned AnimationInstances' time factors and add and remove them from SpaceStates as appropriate to match its own time factor and assigned SpaceState.
Constructor and Description |
---|
SpaceObject(CellVector position)
Creates a new SpaceObject with a new PointHitbox at the specified
position as its locator Hitbox.
|
SpaceObject(Hitbox<T> locatorHitbox)
Creates a new SpaceObject with the specified locator Hitbox.
|
SpaceObject(long x,
long y)
Creates a new SpaceObject with a new PointHitbox at the specified
position as its locator Hitbox.
|
Modifier and Type | Method and Description |
---|---|
double |
angleTo(SpaceObject object)
Returns the angle from this SpaceObject's center to the specified
SpaceObject's center.
|
<O extends SpaceObject<T>> |
boundingBoxesMeet(java.lang.Class<O> cls)
Returns all of the SpaceObjects of the specified class in this
SpaceObject's SpaceState whose overlap Hitboxes' rectangular bounding
boxes touch or intersect this SpaceObject's overlap Hitbox's rectangular
bounding box.
|
void |
changeAngle(double angle)
Changes this SpaceObject's angle of rotation by the specified amount.
|
void |
changePosition(CellVector change)
Changes this SpaceObject's position by the specified amount.
|
void |
changePosition(long changeX,
long changeY)
Changes the coordinates of this SpaceObject's position by the specified
amounts.
|
void |
changeX(long changeX)
Changes the x-coordinate of this SpaceObject's position by the specified
amount.
|
void |
changeY(long changeY)
Changes the y-coordinate of this SpaceObject's position by the specified
amount.
|
void |
clearAnimInstances()
Removes from this SpaceObject all AnimationInstances that are currently
assigned to it.
|
long |
distanceTo(SpaceObject object)
Returns the distance from this SpaceObject's center to the specified
SpaceObject's center.
|
void |
draw(org.newdawn.slick.Graphics g,
int x,
int y,
int x1,
int y1,
int x2,
int y2)
Draws this SpaceObject as seen through a Viewport's camera.
|
void |
flipX()
Flips this SpaceObject horizontally, making it flipped if it was not
before and not flipped if it was before.
|
void |
flipY()
Flips this SpaceObject vertically, making it flipped if it was not before
and not flipped if it was before.
|
double |
getAlpha()
Returns this SpaceObject's alpha value.
|
double |
getAngle()
Returns this SpaceObject's angle of rotation.
|
long |
getAngleX()
Returns the x-coordinate of the unit vector that points in the direction
of this SpaceObject's angle of rotation.
|
long |
getAngleY()
Returns the y-coordinate of the unit vector that points in the direction
of this SpaceObject's angle of rotation.
|
Animation |
getAnimation()
Returns the Animation of the AnimationInstance assigned to this
SpaceObject with ID 0, or Animation.BLANK if there is none.
|
Animation |
getAnimation(int id)
Returns the Animation of the AnimationInstance assigned to this
SpaceObject with the specified ID, or Animation.BLANK if there is none.
|
AnimationInstance |
getAnimInstance()
Returns the AnimationInstance that is assigned to this SpaceObject with
ID 0, or AnimationInstance.BLANK if there is none.
|
AnimationInstance |
getAnimInstance(int id)
Returns the AnimationInstance that is assigned to this SpaceObject with
the specified ID, or AnimationInstance.BLANK if there is none.
|
Drawable |
getAppearance()
Returns this SpaceObject's appearance.
|
long |
getBottomEdge()
Returns the y-coordinate of this SpaceObject's absolute bottom boundary.
|
CellVector |
getCenter()
Returns the absolute position of this SpaceObject's center.
|
CellVector |
getCenterOffset()
Returns this SpaceObject's center's offset.
|
long |
getCenterOffsetX()
Returns the x-coordinate of this SpaceObject's center's offset.
|
long |
getCenterOffsetY()
Returns the y-coordinate of this SpaceObject's center's offset.
|
long |
getCenterX()
Returns the absolute x-coordinate of this SpaceObject's center.
|
long |
getCenterY()
Returns the absolute y-coordinate of this SpaceObject's center.
|
int |
getDrawPriority()
Returns this SpaceObject's draw priority.
|
long |
getEffectiveTimeFactor()
Returns this SpaceObject's effective time factor; that is, the average
number of time units it experiences every frame.
|
Filter |
getFilter()
Returns this SpaceObject's Filter, or null if it has none.
|
T |
getGame()
Returns the CellGame of the SpaceState to which this SpaceObject is
assigned, or null if it is not assigned to a SpaceState.
|
SpaceState<T> |
getGameState()
Returns the SpaceState to which this SpaceObject is assigned, or null if
it is not assigned to one.
|
long |
getLeftEdge()
Returns the x-coordinate of this SpaceObject's absolute left boundary.
|
Hitbox |
getLocatorHitbox()
Returns this SpaceObject's locator Hitbox.
|
SpaceState<T> |
getNewGameState()
Returns the SpaceState to which this SpaceObject is about to be assigned,
but has not yet been due to one or more of the object lists involved
being iterated over.
|
Hitbox |
getOverlapHitbox()
Returns this SpaceObject's overlap Hitbox, or null if it has none.
|
CellVector |
getPosition()
Returns this SpaceObject's position.
|
long |
getRightEdge()
Returns the x-coordinate of this SpaceObject's absolute right boundary.
|
Hitbox |
getSolidHitbox()
Returns this SpaceObject's solid Hitbox, or null if it has none.
|
long |
getTimeFactor()
Returns this SpaceObject's time factor.
|
long |
getTopEdge()
Returns the y-coordinate of this SpaceObject's absolute top boundary.
|
long |
getX()
Returns the x-coordinate of this SpaceObject's position.
|
boolean |
getXFlip()
Returns whether this SpaceObject is horizontally flipped.
|
int |
getXSign()
Returns -1 if this SpaceObject is horizontally flipped and 1 if it is
not.
|
long |
getY()
Returns the y-coordinate of this SpaceObject's position.
|
boolean |
getYFlip()
Returns whether this SpaceObject is vertically flipped.
|
int |
getYSign()
Returns -1 if this SpaceObject is vertically flipped and 1 if it is not.
|
<O extends SpaceObject<T>> |
intersectingSolidObject(java.lang.Class<O> cls)
Returns a solid SpaceObject of the specified class in this SpaceObject's
SpaceState whose solid Hitbox is overlapping it, or null if there is
none.
|
<O extends SpaceObject<T>> |
intersectingSolidObjects(java.lang.Class<O> cls)
Returns all of the solid SpaceObjects of the specified class in this
SpaceObject's SpaceState whose solid Hitboxes are overlapping it.
|
<O extends SpaceObject<T>> |
isIntersectingSolidObject(java.lang.Class<O> cls)
Returns whether this SpaceObject is overlapping the solid Hitbox of a
solid SpaceObject of the specified class in its SpaceState.
|
<O extends SpaceObject<T>> |
isOverlappingObject(java.lang.Class<O> cls)
Returns whether this SpaceObject is overlapping a SpaceObject of the
specified class in its SpaceState.
|
boolean |
isSolid()
Returns whether any of this SpaceObject's surfaces are solid.
|
boolean |
isVisible()
Returns whether any part of this SpaceObject's rectangular bounding box
is visible through any of its SpaceState's Viewports.
|
boolean |
isVisible(Viewport viewport)
Returns whether any part of this SpaceObject's rectangular bounding box
is visible through the specified Viewport.
|
<O extends SpaceObject<T>> |
nearestObject(java.lang.Class<O> cls)
Returns the SpaceObject of the specified class in this SpaceObject's
SpaceState that is nearest to it.
|
<O extends SpaceObject<T>> |
nearestObjectWithinCircle(CellVector center,
long radius,
java.lang.Class<O> cls)
Returns the SpaceObject of the specified class within the specified
circular region in this SpaceObject's SpaceState that is nearest to it.
|
<O extends SpaceObject<T>> |
nearestObjectWithinCircle(long centerX,
long centerY,
long radius,
java.lang.Class<O> cls)
Returns the SpaceObject of the specified class within the specified
circular region in this SpaceObject's SpaceState that is nearest to it.
|
<O extends SpaceObject<T>> |
nearestObjectWithinRadius(long radius,
java.lang.Class<O> cls)
Returns the SpaceObject of the specified class within the specified
radius of this SpaceObject in its SpaceState that is nearest to it.
|
<O extends SpaceObject<T>> |
nearestObjectWithinRectangle(long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns the SpaceObject of the specified class within the specified
rectangular region in this SpaceObject's SpaceState that is nearest to
it.
|
<O extends SpaceObject<T>> |
nearestOverlappingObject(Hitbox hitbox,
java.lang.Class<O> cls)
Returns the SpaceObject of the specified class that overlaps the
specified Hitbox in this SpaceObject's SpaceState that is nearest to it.
|
<O extends SpaceObject<T>> |
objectIsWithinRadius(long radius,
java.lang.Class<O> cls)
Returns whether there are any SpaceObjects of the specified class within
the specified radius of this SpaceObject in its SpaceState.
|
<O extends SpaceObject<T>> |
objectsWithinRadius(long radius,
java.lang.Class<O> cls)
Returns all of the SpaceObjects of the specified class within the
specified radius of this SpaceObject in its SpaceState.
|
<O extends SpaceObject<T>> |
objectWithinRadius(long radius,
java.lang.Class<O> cls)
Returns a SpaceObject of the specified class within the specified radius
of this SpaceObject in its SpaceState, or null if there is none.
|
static <T extends CellGame> |
overlap(SpaceObject<T> object1,
SpaceObject<T> object2)
Returns whether the two specified SpaceObjects overlap.
|
<O extends SpaceObject<T>> |
overlappingObject(java.lang.Class<O> cls)
Returns a SpaceObject of the specified class in this SpaceObject's
SpaceState that is overlapping it, or null if there is none.
|
<O extends SpaceObject<T>> |
overlappingObjects(java.lang.Class<O> cls)
Returns all of the SpaceObjects of the specified class in this
SpaceObject's SpaceState that are overlapping it.
|
boolean |
overlaps(SpaceObject<T> object)
Returns whether this SpaceObject overlaps the specified SpaceObject.
|
void |
setAlpha(double alpha)
Sets this SpaceObject's alpha value to the specified value.
|
void |
setAngle(double angle)
Sets this SpaceObject's angle of rotation to the specified value.
|
AnimationInstance |
setAnimation(Animation animation)
Sets this SpaceObject's AnimationInstance with ID 0 to a new
AnimationInstance of the specified Animation, if there is not already an
AnimationInstance of that Animation assigned with ID 0, then sets this
SpaceObject's appearance to its AnimationInstance with ID 0.
|
AnimationInstance |
setAnimation(int id,
Animation animation)
Sets the AnimationInstance that is assigned to this SpaceObject with the
specified ID to a new AnimationInstance of the specified Animation, if
there is not already an AnimationInstance of that Animation assigned
with that ID.
|
boolean |
setAnimInstance(AnimationInstance instance)
Sets both this SpaceObject's appearance and its AnimationInstance with ID
0 to the specified AnimationInstance, if it is not already assigned to a
CellGameState.
|
boolean |
setAnimInstance(int id,
AnimationInstance instance)
Sets the AnimationInstance that is assigned to this SpaceObject with the
specified ID to the specified AnimationInstance, if it is not already
assigned to a CellGameState.
|
void |
setAppearance(Drawable appearance)
Sets this SpaceObject's appearance to the specified Drawable.
|
void |
setCenterOffset(CellVector offset)
Sets this SpaceObject's center's offset to the specified value.
|
void |
setCenterOffset(long x,
long y)
Sets the coordinates of this SpaceObject's center's offset to the
specified values.
|
void |
setCenterOffsetX(long x)
Sets the x-coordinate of this SpaceObject's center's offset to the
specified value.
|
void |
setCenterOffsetY(long y)
Sets the y-coordinate of this SpaceObject's center's offset to the
specified value.
|
void |
setDrawPriority(int drawPriority)
Sets this SpaceObject's draw priority to the specified value.
|
void |
setFilter(Filter filter)
Sets this SpaceObject's Filter to the specified Filter, or to none if the
specified Filter is null.
|
void |
setGameState(SpaceState<T> state)
Sets the SpaceState to which this SpaceObject is assigned.
|
boolean |
setLocatorHitbox(Hitbox<T> locatorHitbox)
Sets this SpaceObject's locator Hitbox to the specified Hitbox.
|
boolean |
setOverlapHitbox(Hitbox<T> overlapHitbox)
Sets this SpaceObject's overlap Hitbox to the specified Hitbox.
|
void |
setPosition(CellVector position)
Sets this SpaceObject's position to the specified value.
|
void |
setPosition(long x,
long y)
Sets this SpaceObject's position to the specified value.
|
void |
setSolid(boolean solid)
Sets whether this SpaceObject's surfaces in every direction are solid.
|
boolean |
setSolidHitbox(Hitbox solidHitbox)
Sets this SpaceObject's solid Hitbox to the specified Hitbox.
|
void |
setSurfaceSolid(Direction direction,
boolean solid)
Sets whether this SpaceObject's surface in the specified Direction is
solid.
|
void |
setTimeFactor(long timeFactor)
Sets this SpaceObject's time factor to the specified value.
|
void |
setX(long x)
Sets the x-coordinate of this SpaceObject's position to the specified
value.
|
void |
setXFlip(boolean xFlip)
Sets whether this SpaceObject is horizontally flipped.
|
void |
setY(long y)
Sets the y-coordinate of this SpaceObject's position to the specified
value.
|
void |
setYFlip(boolean yFlip)
Sets whether this SpaceObject is vertically flipped.
|
boolean |
surfaceIsSolid(Direction direction)
Returns whether this SpaceObject's surface in the specified Direction is
solid.
|
public SpaceObject(Hitbox<T> locatorHitbox)
locatorHitbox
- This SpaceObject's locator Hitboxpublic SpaceObject(CellVector position)
position
- This SpaceObject's positionpublic SpaceObject(long x, long y)
x
- The x-coordinate of this SpaceObject's positiony
- The y-coordinate of this SpaceObject's positionpublic final T getGame()
public final SpaceState<T> getGameState()
public final SpaceState<T> getNewGameState()
public final void setGameState(SpaceState<T> state)
state
- The SpaceState to which this SpaceObject should be assignedpublic final long getTimeFactor()
public final long getEffectiveTimeFactor()
public final void setTimeFactor(long timeFactor)
timeFactor
- The new time factorpublic final Hitbox getLocatorHitbox()
public final boolean setLocatorHitbox(Hitbox<T> locatorHitbox)
locatorHitbox
- The new locator Hitboxpublic final CellVector getPosition()
public final long getX()
public final long getY()
public final void setPosition(CellVector position)
position
- The new positionpublic final void setPosition(long x, long y)
x
- The x-coordinate of the new positiony
- The y-coordinate of the new positionpublic final void setX(long x)
x
- The x-coordinate of the new positionpublic final void setY(long y)
y
- The y-coordinate of the new positionpublic final void changePosition(CellVector change)
change
- The amount to change the position bypublic final void changePosition(long changeX, long changeY)
changeX
- The amount to change the position's x-coordinate bychangeY
- The amount to change the position's y-coordinate bypublic final void changeX(long changeX)
changeX
- The amount to change the position's x-coordinate bypublic final void changeY(long changeY)
changeY
- The amount to change the position's y-coordinate bypublic final boolean getXFlip()
public final int getXSign()
public final void setXFlip(boolean xFlip)
xFlip
- Whether this SpaceObject should be horizontally flippedpublic final void flipX()
public final boolean getYFlip()
public final int getYSign()
public final void setYFlip(boolean yFlip)
yFlip
- Whether this SpaceObject should be vertically flippedpublic final void flipY()
public final double getAngle()
public final long getAngleX()
public final long getAngleY()
public final void setAngle(double angle)
angle
- The new angle of rotationpublic final void changeAngle(double angle)
angle
- The amount to change the angle of rotation bypublic final long getLeftEdge()
public final long getRightEdge()
public final long getTopEdge()
public final long getBottomEdge()
public final CellVector getCenterOffset()
public final long getCenterOffsetX()
public final long getCenterOffsetY()
public final void setCenterOffset(CellVector offset)
offset
- This SpaceObject's center's new offsetpublic final void setCenterOffset(long x, long y)
x
- The new x-coordinate of this SpaceObject's center's offsety
- The new y-coordinate of this SpaceObject's center's offsetpublic final void setCenterOffsetX(long x)
x
- The new x-coordinate of this SpaceObject's center's offsetpublic final void setCenterOffsetY(long y)
y
- The new y-coordinate of this SpaceObject's center's offsetpublic final CellVector getCenter()
public final long getCenterX()
public final long getCenterY()
public final long distanceTo(SpaceObject object)
object
- The SpaceObject to return the distance topublic final double angleTo(SpaceObject object)
object
- The SpaceObject to return the angle topublic final <O extends SpaceObject<T>> O nearestObject(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinRectangle(long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forx1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinCircle(CellVector center, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenter
- The region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinCircle(long centerX, long centerY, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenterX
- The x-coordinate of the region's centercenterY
- The y-coordinate of the region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestOverlappingObject(Hitbox hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean objectIsWithinRadius(long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forradius
- The radius of this SpaceObject to search withincls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O objectWithinRadius(long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forradius
- The radius of this SpaceObject to search withincls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> objectsWithinRadius(long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forradius
- The radius of this SpaceObject to search withincls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinRadius(long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forradius
- The radius of this SpaceObject to search withincls
- The Class object that represents the SpaceObject subclasspublic final Hitbox getOverlapHitbox()
public final boolean setOverlapHitbox(Hitbox<T> overlapHitbox)
overlapHitbox
- The new overlap Hitboxpublic final boolean overlaps(SpaceObject<T> object)
object
- The SpaceObject to check for an overlappublic static <T extends CellGame> boolean overlap(SpaceObject<T> object1, SpaceObject<T> object2)
T
- The subclass of CellGame that uses the SpaceStates that the
two SpaceObjects can be assigned toobject1
- The first SpaceObjectobject2
- The second SpaceObjectpublic final <O extends SpaceObject<T>> boolean isOverlappingObject(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O overlappingObject(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> overlappingObjects(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> boundingBoxesMeet(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean isIntersectingSolidObject(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O intersectingSolidObject(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> intersectingSolidObjects(java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcls
- The Class object that represents the SpaceObject subclasspublic final Hitbox getSolidHitbox()
public final boolean setSolidHitbox(Hitbox solidHitbox)
solidHitbox
- The new solid Hitboxpublic final boolean isSolid()
public final boolean surfaceIsSolid(Direction direction)
direction
- The Direction of the surface to be examinedpublic final void setSurfaceSolid(Direction direction, boolean solid)
direction
- The Direction of the surface whose solidity is to be setsolid
- Whether the surface in the specified Direction should be
solidpublic final void setSolid(boolean solid)
solid
- Whether this SpaceObject's surfaces in every direction
should be solidpublic final int getDrawPriority()
public final void setDrawPriority(int drawPriority)
drawPriority
- The new draw prioritypublic final Drawable getAppearance()
public final void setAppearance(Drawable appearance)
appearance
- The new appearancepublic final AnimationInstance getAnimInstance(int id)
id
- The ID of the AnimationInstance to be returnedpublic final AnimationInstance getAnimInstance()
public final boolean setAnimInstance(int id, AnimationInstance instance)
id
- The ID with which to assign the specified AnimationInstanceinstance
- The AnimationInstance to add with the specified IDpublic final boolean setAnimInstance(AnimationInstance instance)
instance
- The new appearance and AnimationInstance with ID 0public final Animation getAnimation(int id)
id
- The ID of the AnimationInstance whose Animation is to be
returnedpublic final Animation getAnimation()
public final AnimationInstance setAnimation(int id, Animation animation)
id
- The ID with which to assign the new AnimationInstanceanimation
- The Animation to add a new AnimationInstance ofpublic final AnimationInstance setAnimation(Animation animation)
animation
- The Animation to add a new AnimationInstance ofpublic final void clearAnimInstances()
public final double getAlpha()
public final void setAlpha(double alpha)
alpha
- The new alpha valuepublic final Filter getFilter()
public final void setFilter(Filter filter)
filter
- The new Filterpublic final boolean isVisible()
public final boolean isVisible(Viewport viewport)
viewport
- The Viewport to checkpublic void draw(org.newdawn.slick.Graphics g, int x, int y, int x1, int y1, int x2, int y2)
g
- The Graphics context to which this SpaceObject is being drawn
this framex
- The x-coordinate in pixels on the Graphics context that
corresponds to the x-coordinate of this SpaceObject's positiony
- The y-coordinate in pixels on the Graphics context that
corresponds to the y-coordinate of this SpaceObject's positionx1
- 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