|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.gameEngine.game.GameRelatedObject
vooga.gameEngine.controller.GameRelatedController
vooga.gameEngine.controller.CameraController
public class CameraController
This class represents the connection between the game and the camera. This
class can be extended to implement listener methods for all relevant events.
This class also fires a PositionChangedEvent
when the camera is moved
and a SizeChangedEvent
when the camera is resized and a
RotationChangedEvent
when the camera is rotated; any object who wants
to listen for these events should implement CameraListener
.
For example to make the camera follow mario you would make your own
CameraController
class say myCameraController
and
add mario to it
CameraController myCamera = new myCameraController();
GameItem mario = new MarioCharacter();
mario.add(myCamera);
If mario
fires a MoveRight
event and the
CameraController
implements a MarioListener
with
the method:
public void moveCameraRight(MoveRight event);
then this method
will be called whenever a MoveRight
event is fired.
Constructor Summary | |
---|---|
CameraController(Position p,
Dimension size)
Creates a new CameraController with the top left corner at a
Position p and with a Dimension ,
viewableArea, representing the viewable area in terms of the game
coordinate system. |
|
CameraController(Position p,
Dimension size,
Rotation2D rotation)
Creates a new CameraController with the top left corner at a
Position p and with a Dimension ,
viewableArea, representing the viewable area in terms of the game
coordinate system. |
Method Summary | |
---|---|
java.awt.geom.Rectangle2D |
getBounds()
Deprecated. |
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. |
Dimension |
getViewableArea()
Deprecated. |
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 |
move(Position pointToMoveTo)
Deprecated. |
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 |
setViewableArea(Dimension viewableArea)
Deprecated. |
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 CameraController(Position p, Dimension size, Rotation2D rotation)
CameraController
with the top left corner at a
Position
p and with a Dimension
,
viewableArea, representing the viewable area in terms of the game
coordinate system.
p
- is starting positionviewableArea
- the area the camera can seeorientation
- the initial orientation of the camerapublic CameraController(Position p, Dimension size)
CameraController
with the top left corner at a
Position
p and with a Dimension
,
viewableArea, representing the viewable area in terms of the game
coordinate system. A default Rotation2D
is used to represent
the rotation of this object.
p
- is starting positionviewableArea
- the area the camera can seeMethod Detail |
---|
@Deprecated public void move(Position pointToMoveTo)
Position
of the top left corner. Fires
PositionChangedEvent
.
pointToMoveTo
- place to move the camera topublic 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 Position getPosition()
Tangible
getPosition
in interface Tangible
Position
representing current position@Deprecated public Dimension getViewableArea()
@Deprecated public void setViewableArea(Dimension viewableArea)
SizedChangedEvent
.
viewableArea
- seen by the camera in terms of the game's coordinate system@Deprecated public java.awt.geom.Rectangle2D getBounds()
Rectangle2D
representing the area that can
be rendered on screen.
public Rotation2D getRotation()
Tangible
getRotation
in interface Tangible
Rotation2D
representing current
rotationpublic Dimension getSize()
Tangible
getSize
in interface Tangible
Dimension
representing current sizepublic 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 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 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 void setRotation(Rotation2D r)
Tangible
Rotation2D
.
Fires a RotationChangedEvent
when called.
setRotation
in interface Tangible
r
- is new rotation of the objectpublic 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 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 |