|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.gameEngine.game.GameRelatedObject
vooga.gameEngine.item.GameItem
public class GameItem
Every item that will be displayed on screen in a game must extend the
GameItem
class. This class ensures that items created for a game
are Renderable
and extend a GameRelatedObject
.
Constructor Summary | |
---|---|
GameItem(Texture t)
Creates a GameItem set to visible by default. |
Method Summary | |
---|---|
int |
compareTo(Renderable o)
|
Position |
getPosition()
Getter method for the current position of this item in the coordinate system used by the game. |
Rotation2D |
getRotation()
Getter method for the current rotation of this item in the coordinate system used by the game. |
java.awt.Shape |
getShape()
Method for getting a Shape representing the area that can be
rendered on screen. |
Dimension |
getSize()
Getter method for the current dimension of this item in the coordinate system used by the game. |
Texture |
getTexture()
Getter method for the current Texture of this item. |
boolean |
isVisible()
Gives the visibility status of the GameItem . |
void |
move(double dx,
double dy)
Moves this object dx to the right and dy up, which is relative to the in game coordinate system. |
void |
resize(double dx,
double dy)
Change's the size of this object dx in width and dy in height, which is relative to the in game coordinate system. |
void |
rotate(double dtheta)
Rotates this object dtheta clockwise, which is relative to the Position defined the existing Rotation2D
associated with this object. |
void |
setPosition(Position p)
Moves this object to a specified Position . |
void |
setRotation(Rotation2D r)
Changes this object's rotation to the specified Rotation2D . |
void |
setSize(Dimension d)
Changes this object's size to a specified Dimension . |
void |
setVisibility(boolean visible)
Sets the visibility status of the GameItem . |
Methods inherited from class vooga.gameEngine.game.GameRelatedObject |
---|
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GameItem(Texture t)
GameItem
set to visible by default.
t
- is the Texture
representing the
GameItem
Method Detail |
---|
public final boolean isVisible()
Renderable
GameItem
.
isVisible
in interface Renderable
public final void setVisibility(boolean visible)
Renderable
GameItem
.
setVisibility
in interface Renderable
visible
- if true, if not falsepublic final Position getPosition()
Tangible
getPosition
in interface Tangible
Position
representing current positionpublic final Dimension getSize()
Tangible
getSize
in interface Tangible
Dimension
representing current sizepublic final Rotation2D getRotation()
Tangible
getRotation
in interface Tangible
Rotation2D
representing current
rotationpublic final void move(double dx, double dy)
Tangible
PositionChangedEvent
when called.
move
in interface Tangible
dx
- the change in the x-axisdy
- the change in the y-axispublic final void resize(double dx, double dy)
Tangible
SizeChangedEvent
when called.
resize
in interface Tangible
dx
- the change in the widthdy
- the change in the heightpublic final void rotate(double dtheta)
Tangible
Position
defined the existing Rotation2D
associated with this object. Fires a RotationChangedEvent
when
called.
rotate
in interface Tangible
dtheta
- is the angle to rotate the object in radianspublic final void setPosition(Position p)
Tangible
Position
. Fires a
PositionChangedEvent
when called.
setPosition
in interface Tangible
p
- new position of the object (top left corner)public final void setSize(Dimension d)
Tangible
Dimension
. Fires a
SizeChangedEvent
when called.
setSize
in interface Tangible
d
- is new dimension of the object in the game's coordinate systempublic final void setRotation(Rotation2D r)
Tangible
Rotation2D
.
Fires a RotationChangedEvent
when called.
setRotation
in interface Tangible
r
- is new rotation of the objectpublic final int compareTo(Renderable o)
compareTo
in interface java.lang.Comparable<Renderable>
public final Texture getTexture()
Renderable
Texture
of this item. The
texture represents how the GameItem
is displayed on the
screen. The dimensions of the Texture
should be relative to
the coordinate system used in the game.
getTexture
in interface Renderable
public final java.awt.Shape getShape()
Tangible
Shape
representing the area that can be
rendered on screen.
getShape
in interface Tangible
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |