public class Camera extends java.lang.Object implements LinkedWithMap
Constructor and Description |
---|
Camera(AbstractEntity focusentity,
int x,
int y,
int width,
int height,
GameView view)
Creates a camera focusing an entity.
|
Camera(GameView view)
Creates a fullscale camera pointing at the middle of the map.
|
Camera(int x,
int y,
int width,
int height,
GameView view)
Creates a camera pointing at the middle of the map.
|
Camera(Point center,
int x,
int y,
int width,
int height,
GameView view)
Create a camera focusin a specific coordinate.
|
Modifier and Type | Method and Description |
---|---|
Point |
getCenter()
Returns the focuspoint
|
int |
getCoveredBackBorder()
Clipping
|
int |
getCoveredFrontBorder() |
int |
getCoveredLeftBorder()
Get the leftmost block-coordinate covered by the camera.
|
int |
getCoveredRightBorder()
Get the rightmost block-coordinate covered by the camera viewFrustum.
|
int |
getHeightInProjSpc()
The amount of game pixel which are visible in Y direction after the zoom
has been applied.
|
int |
getHeightInScreenSpc()
Returns the height of the camera output.
|
int |
getHeightInViewSpc()
The amount of game pixel which are visible in Y direction without zoom.
|
int |
getScreenPosX()
Returns the position of the cameras output (on the screen)
|
int |
getScreenPosY()
Returns the position of the camera (on the screen)
|
float |
getScreenSpaceScaling()
Returns a scaling factor calculated by the width to achieve the same
viewport size with every resolution
|
float |
getViewSpaceX()
The Camera Position in the game world.
|
float |
getViewSpaceY()
The Camera's center position in the game world. view space. yIndex up
|
int |
getVisibleBackBorder()
Returns the top seight border of the camera covered groundBlock
|
int |
getVisibleFrontBorderHigh()
Returns the bottom seight border y-coordinate of the highest block
|
int |
getVisibleFrontBorderLow()
Returns the bottom seight border y-coordinate of the lowest block
|
int |
getVisibleLeftBorder()
Returns the left border of the visible area.
|
int |
getVisibleRightBorder()
Returns the right seight border of the camera covered area currently visible.
|
int |
getWidthInProjSpc()
The amount of game world pixels which are visible in X direction after
the zoom has been applied.
|
int |
getWidthInScreenSpc()
Returns the width of the camera output.
|
int |
getWidthInViewSpc()
The amount of game pixel which are visible in X direction without zoom.
|
float |
getZoom()
Returns the zoomfactor.
|
int |
getZRenderingLimit() |
protected void |
hiddenSurfaceDetection()
performs a simple viewFrustum check by looking at the direct neighbours.
|
boolean |
isClipped(Coordinate coords)
get if a coordinate is clipped
|
boolean |
isFullWindow()
Does the cameras output cover the whole screen?
|
void |
move(int x,
int y)
Move xIndex and yIndex coordinate
|
void |
onChunkChange(Chunk chunk)
called if a chunk's content (blocks) changes.
|
void |
onMapChange()
called if the map content (blocks) changes.
|
void |
orientationChange() |
void |
render(GameView view,
Camera camera)
Renders the viewport
|
void |
resize(int width,
int height)
Should be called when resized
|
void |
setActive(boolean active)
enable or disable the camera
|
void |
setDamageoverlayOpacity(float opacity) |
void |
setFullWindow(boolean fullWindow)
Set to true if the camera's output should cover the whole window
|
void |
setScreenSize(int width,
int height)
updates the screen size
|
void |
setZoom(float zoom)
Set the zoom factor and regenerates the sprites.
|
void |
setZRenderingLimit(int limit)
If the limit is set to the map's height or more it becomes deactivated.
|
void |
shake(float amplitude,
float time)
shakes the screen
|
void |
update(float dt)
Updates the camera.
|
protected void |
updateCache()
updates cached values like clipping
|
void |
updateCenter()
Check if center has to be moved and if chunks must be loaded or unloaded performs according actions.
|
void |
updateViewSpaceSize()
updates the cache
|
public Camera(int x, int y, int width, int height, GameView view)
x
- the position in the application window (viewport position).
Origin top lefty
- the position in the application window (viewport position).
Origin top leftwidth
- The width of the image (screen size) the camera creates on
the application window (viewport)height
- The height of the image (screen size) the camera creates on
the application window (viewport)view
- public Camera(GameView view)
view
- public Camera(Point center, int x, int y, int width, int height, GameView view)
center
- the point where the camera focusesx
- the position in the application window (viewport position).
Origin top lefty
- the position in the application window (viewport position).
Origin top leftwidth
- The width of the image (screen size) the camera creates on
the application window (viewport)height
- The height of the image (screen size) the camera creates on
the application window (viewport)view
- public Camera(AbstractEntity focusentity, int x, int y, int width, int height, GameView view)
focusentity
- the entity wich the camera focuses and followsx
- the position in the application window (viewport position).
Origin top lefty
- the position in the application window (viewport position).
Origin top leftwidth
- The width of the image (screen size) the camera creates on
the application window (viewport)height
- The height of the image (screen size) the camera creates on
the application window (viewport)view
- public final void update(float dt)
dt
- public void updateCenter()
public void render(GameView view, Camera camera)
view
- camera
- protected void updateCache()
protected void hiddenSurfaceDetection()
public void setZoom(float zoom)
zoom
- public float getZoom()
public float getScreenSpaceScaling()
public int getZRenderingLimit()
public void setZRenderingLimit(int limit)
limit
- minimum is 0, everything to this limit becomes renderedpublic int getVisibleLeftBorder()
public int getCoveredLeftBorder()
public int getVisibleRightBorder()
public int getCoveredRightBorder()
public int getVisibleBackBorder()
public int getCoveredBackBorder()
public int getVisibleFrontBorderLow()
getVisibleFrontBorderHigh()
public int getVisibleFrontBorderHigh()
getVisibleFrontBorderLow()
public int getCoveredFrontBorder()
public float getViewSpaceX()
public float getViewSpaceY()
public final int getWidthInViewSpc()
getWidthInScreenSpc()
.public final int getHeightInViewSpc()
getHeightInScreenSpc()
.public final void updateViewSpaceSize()
public final int getWidthInProjSpc()
getWidthInScreenSpc()
.public final int getHeightInProjSpc()
getHeightInScreenSpc()
.public int getScreenPosX()
public int getScreenPosY()
public int getHeightInScreenSpc()
public int getWidthInScreenSpc()
public boolean isFullWindow()
public void setFullWindow(boolean fullWindow)
fullWindow
- public void resize(int width, int height)
width
- width of windowheight
- height of windowpublic void setScreenSize(int width, int height)
width
- height
- public void move(int x, int y)
x
- in game space if has focusentity, else in view space (?)y
- in game space if has focusentity, else in view space (?)public void setDamageoverlayOpacity(float opacity)
opacity
- public void shake(float amplitude, float time)
amplitude
- time
- public void onMapChange()
LinkedWithMap
onMapChange
in interface LinkedWithMap
public void onChunkChange(Chunk chunk)
LinkedWithMap
onChunkChange
in interface LinkedWithMap
chunk
- the chunk that changedpublic Point getCenter()
public boolean isClipped(Coordinate coords)
coords
- public void orientationChange()
public void setActive(boolean active)
active
-