C# Class Nez.FollowCamera

basic follow camera. LockOn mode uses no deadzone and just centers the camera on the target. CameraWindow mode wraps a deadzone around the target allowing it to move within the deadzone without moving the camera.
Inheritance: Component, IUpdatable
Exibir arquivo Open project: prime31/Nez

Public Properties

Property Type Description
camera Camera
deadzone RectangleF
focusOffset Vector2
followLerp float
mapLockEnabled bool
mapSize Vector2

Public Methods

Method Description
FollowCamera ( System.Entity targetEntity ) : System
FollowCamera ( System.Entity targetEntity, Camera camera ) : System
IUpdatable ( ) : void
debugRender ( Graphics graphics ) : void
follow ( System.Entity targetEntity, CameraStyle cameraStyle = CameraStyle.CameraWindow ) : void
onAddedToEntity ( ) : void
onGraphicsDeviceReset ( ) : void
onRemovedFromEntity ( ) : void
setCenteredDeadzone ( int width, int height ) : void

sets up the deadzone centered in the current cameras bounds with the given size

updateFollow ( ) : void

Private Methods

Method Description
clampToMapSize ( Vector2 position ) : Vector2

Clamps the camera so it never leaves the visible area of the map.

Method Details

FollowCamera() public method

public FollowCamera ( System.Entity targetEntity ) : System
targetEntity System.Entity
return System

FollowCamera() public method

public FollowCamera ( System.Entity targetEntity, Camera camera ) : System
targetEntity System.Entity
camera Camera
return System

IUpdatable() public method

public IUpdatable ( ) : void
return void

debugRender() public method

public debugRender ( Graphics graphics ) : void
graphics Graphics
return void

follow() public method

public follow ( System.Entity targetEntity, CameraStyle cameraStyle = CameraStyle.CameraWindow ) : void
targetEntity System.Entity
cameraStyle CameraStyle
return void

onAddedToEntity() public method

public onAddedToEntity ( ) : void
return void

onGraphicsDeviceReset() public method

public onGraphicsDeviceReset ( ) : void
return void

onRemovedFromEntity() public method

public onRemovedFromEntity ( ) : void
return void

setCenteredDeadzone() public method

sets up the deadzone centered in the current cameras bounds with the given size
public setCenteredDeadzone ( int width, int height ) : void
width int Width.
height int Height.
return void

updateFollow() public method

public updateFollow ( ) : void
return void

Property Details

camera public_oe property

public Camera,Nez camera
return Camera

deadzone public_oe property

when in CameraWindow mode the width/height is used as a bounding box to allow movement within it without moving the camera. when in LockOn mode only the deadzone x/y values are used. This is set to sensible defaults when you call follow but you are free to override it to get a custom deadzone directly or via the helper setCenteredDeadzone.
public RectangleF deadzone
return RectangleF

focusOffset public_oe property

offset from the screen center that the camera will focus on
public Vector2 focusOffset
return Vector2

followLerp public_oe property

how fast the camera closes the distance to the target position
public float followLerp
return float

mapLockEnabled public_oe property

If true, the camera position will not got out of the map rectangle (0,0, mapwidth, mapheight)
public bool mapLockEnabled
return bool

mapSize public_oe property

Contains the width and height of the current map.
public Vector2 mapSize
return Vector2