|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.HObject hermes.Being hermes.HCamera
public class HCamera
HCamera
determines which Being
s get drawn. You can think of it as a window into the World
,
and any Being
s that are inside of its bounding box will have their draw()
methods called automatically.
The World
class needs to be passed an HCamera
when constructed.
Any Being
(s) registered with that World
will automatically get drawn if they are
spatially within that HCamera
's bounding box.
An HCamera
's bounding box is determined at construction - by default, it uses the pixel width and height of the PApplet that was passed to Hermes
.
Alternatively, HCamera
has an alternate constructor that allows you to set your own custom screen to world coordinate ratio.
If you wish to use a coordinate system other than pixels coordinates, simply set the width and height of the camera to the area of the world you want the camera to see at a time.
HCamera
extends Being
, which allows it to move around and interact with other entities in the game.
This opens interesting possibilities, such as having a camera follow a character, having the camera move based on game events or other logic, etc.
Field Summary |
---|
Fields inherited from class hermes.Being |
---|
_position, _shape, _time, _velocity |
Constructor Summary | |
---|---|
HCamera()
Default HCamera constructor. |
|
HCamera(float x,
float y,
float cameraWidth,
float cameraHeight)
Constructs an HCamera with a custom coordinate unit size. |
Method Summary | |
---|---|
void |
addBeing(Being being)
adds a Being to _beings. |
void |
collisionsComplete()
This method is a callback, letting the Camera know that the _beingsPending list has been completed for this timestep, and that it can switch to make it the actively drawn list of Beings on the next call to draw() |
void |
collisionsReset()
Resets internal state parameters, effectively clearing the cache of collided Beings from the last time step |
void |
draw()
This method gets called by Processing's draw thread. |
float |
getScreenToWorldRatioX()
|
float |
getScreenToWorldRatioY()
|
float |
getWorldCoordinateHeight()
|
float |
getWorldCoordinateWidth()
|
void |
setWorldCoordinateHeight(float worldCoordinateHeight)
|
void |
setWorldCoordinateWidth(float worldCoordinateWidth)
|
void |
zoomWithScreenCoordinates(float zoomFactor,
float screenZoomCenterX,
float screenZoomCenterY)
|
void |
zoomWithWorldCoordinates(float zoomFactor,
float worldZoomCenterX,
float worldZoomCenterY)
|
Methods inherited from class hermes.Being |
---|
EulerIntegratePosition, getBoundingBox, getPosition, getShape, getVelocity, getVelocityX, getVelocityY, getX, getY, needsMoreSamples, processUpdate, setDone, setPosition, setPosition, setPosition, setVelocity, setVelocityX, setVelocityY, setX, setY, step, toString, update, updateTime |
Methods inherited from class hermes.HObject |
---|
addToGroup, delete, getGroups, receive, receive, receive, receive, removeFromGroup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HCamera()
public HCamera(float x, float y, float cameraWidth, float cameraHeight)
x
- the starting x coordinate of the cameray
- the starting y coordinate of the cameracameraWidth
- the width of the camera view, in world coordinate units. This determines how far the camera can see in the x direction.cameraHeight
- the height of the camera view. This determines how far the camera can see in the y direction.Method Detail |
---|
public float getWorldCoordinateWidth()
public void setWorldCoordinateWidth(float worldCoordinateWidth)
public float getWorldCoordinateHeight()
public void setWorldCoordinateHeight(float worldCoordinateHeight)
public float getScreenToWorldRatioX()
public float getScreenToWorldRatioY()
public void collisionsReset()
public void collisionsComplete()
public void addBeing(Being being)
being
- public void zoomWithWorldCoordinates(float zoomFactor, float worldZoomCenterX, float worldZoomCenterY)
zoomFactor
- worldZoomCenterX
- worldZoomCenterY
- public void zoomWithScreenCoordinates(float zoomFactor, float screenZoomCenterX, float screenZoomCenterY)
public void draw()
draw
in class Being
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |