Static Member Summary
Static Private Members | ||
private static |
An array of axis. |
|
private static |
The default ease. |
|
private static |
The default pan duration. |
|
private static |
The default tile size of the Vylocity Game Engine. |
|
private static |
The max amount of delta time between ticks. |
|
private static |
The max display an instance can be displayed at. |
|
private static |
An array of valid ease names. |
Constructor Summary
Private Constructor | ||
private |
|
Member Summary
Public Members | ||
public |
The camera that lens controls. |
|
public |
version: * The version of the module. |
Private Members | ||
private |
Whether the camera is attached to something and will follow it. |
|
private |
If this camera is using custom settings currently. |
|
private |
The current instance this camera is following. |
|
private |
Whether the camera has been created and is ready for use or not. |
|
private |
Weakmap to track data belonging to instances used in this module. |
|
private |
The logger module this module uses to log errors / logs. |
|
private |
Whether the mapview has been initialized. |
|
private |
The old position that the camera was following in the last tick. |
|
private |
The settings this camera uses to operate. |
|
private |
updateWithCamera(-: number, -: number): Function | undefined A callback to be called when the camera is updated. |
Method Summary
Public Methods | ||
public |
Attaches the camera to the passed instance. |
|
public |
Stops spectating. |
|
public |
detach() Detaches the camera. |
|
public |
Check if the camera is currently moving. |
|
public |
Check if the camera is currently panning. |
|
public |
Check if the camera is currently shaking. |
|
public |
Check if the camera is currently spectating. |
|
public |
Check if the camera is currently zooming. |
|
public |
Pans the camera from one view to another view. |
|
public |
setSettings(pSettings: Object) Sets the camera to operate using these user defined settings. |
|
public |
Shakes the camera with the passed settings. |
|
public |
Spectates another instance with the camera using the passed settings. |
|
public |
Zooms the camera in via the passed in arguments. |
Private Methods | ||
private |
Method to follow the target of the camera. |
|
private |
followLogic(pAxis: string, pPosition: Object, pMethod: string, pElapsedMS: number) The logic for following instances via the camera. |
|
private |
getTrueCenterPos(pInstance: Object): Object Returns the true center position by using the x and y position and adding half of the icon's width / height. If no icon is found, we instead use the half of the default tileSize. |
|
private |
Builds and initiates the camera and assigns some presets to it |
|
private |
Event handler for when the second part of the pan completes. |
|
private |
onPanned() Event handler for when the first part of the pan completes. |
|
private |
|
|
private |
|
|
private |
Resets the camera based on the method passed. |
|
private |
shakeUpdate(pElapsedMS: number) The method to update shaking when it is active. |
|
private |
Update handler that is called each tick to update the camera's state |
|
private |
zoomUpdate(pElapsedMS: number) The method to update the zoom when it is active. |
Static Private Members
Private Constructors
private constructor() source
Public Members
Private Members
private initialized: boolean source
Whether the camera has been created and is ready for use or not.
private instanceWeakMap: WeakMap source
Weakmap to track data belonging to instances used in this module.
Public Methods
public attach(pInstance: Object, pSettings: Object, pUpdateFunc: Function) source
Attaches the camera to the passed instance.
Params:
Name | Type | Attribute | Description |
pInstance | Object | The instance to attach the camera to |
|
pSettings | Object | An object that holds settings for how the canera will behave. |
|
pSettings.duration | Object | An object that holds settings for how the canera will behave. |
|
pSettings.duration.x | number | The duration of the ease in the x dimension. |
|
pSettings.duration.y | number | The duration of the ease in the y dimension. |
|
pSettings.ease | Object | An object that holds settings for how the canera will behave. |
|
pSettings.ease.x | string | The ease to use in the x dimension. |
|
pSettings.ease.y | string | The ease to use in the y dimension. |
|
pUpdateFunc | Function | A callback that will be called when the camera is updated. pDiffX and pDiffY params are the difference in position between the last tick. |
public cancelSpectate() source
Stops spectating. If the setting 'forcePos' was set. Then the camera will immedietly jump to the original camera target.
public pan(pSettings: Object) source
Pans the camera from one view to another view. This pan can be customized in both axis. This pan has callbacks and settings that allow further customization.
Params:
Name | Type | Attribute | Description |
pSettings | Object | A Object holding settings that control this pan. |
|
pSettings.target | Object | A Object holding settings that control this pan. |
|
pSettings.ease | Object | A Object holding settings that control this pan. |
|
pSettings.ease.x | string | A Object holding settings that control this pan. |
|
pSettings.ease.y | string | A Object holding settings that control this pan. |
|
pSettings.panBackEase | Object | A Object holding settings that control this pan. |
|
pSettings.panBackEase.x | string | A Object holding settings that control this pan. |
|
pSettings.panBackEase.y | string | A Object holding settings that control this pan. |
|
pSettings.duration | Object | A Object holding settings that control this pan. |
|
pSettings.duration.x | number | A Object holding settings that control this pan. |
|
pSettings.duration.y | number | A Object holding settings that control this pan. |
|
pSettings.panBackDuration | Object | A Object holding settings that control the duration of the pan. |
|
pSettings.panBackDuration.x | number | The duration of the ease in the x dimension. |
|
pSettings.panBackDuration.y | number | The duration of the ease in the y dimension. |
|
pSettings.pauseDuration | number | How long the camera will stay at the target after panning to it before completing the pan. |
|
pSettings.attach | boolean | Whether or not to attach the camera to the target when the pan to it is completed. This automatically forfeits the panBack nature of this and no panBack callback will be called. |
|
pSettings.forceDirChange | boolean | Whether panning to a target changes your direction to face the target. |
|
pSettings.panToCallback | Function | Callback function to be called when the pan to the target is completed. |
|
pSettings.panBackCallback | Function | Callback function to be called when the pan from the target back to the camera's target is completed. |
public setSettings(pSettings: Object) source
Sets the camera to operate using these user defined settings.
Params:
Name | Type | Attribute | Description |
pSettings | Object | An object that holds settings for how the canera will behave. |
|
pSettings.duration | Object | An object that holds settings for how the canera will behave. |
|
pSettings.duration.x | number | The duration of the ease in the x dimension. |
|
pSettings.duration.y | number | The duration of the ease in the y dimension. |
|
pSettings.ease | Object | An object that holds settings for how the canera will behave. |
|
pSettings.ease.x | string | The ease to use in the x dimension. |
|
pSettings.ease.y | string | The ease to use in the y dimension. |
public shake(pIntensity: number, pDuration: number, pRotational: boolean, pCallback: Function) source
Shakes the camera with the passed settings.
Params:
Name | Type | Attribute | Description |
pIntensity | number | The intensity of the shaking effect. 0 - 100 |
|
pDuration | number | The duration of the shaking effect in ms. |
|
pRotational | boolean | Whether the shaking consists of rotational shaking as well. |
|
pCallback | Function | Callback function to call when the shaking is completed. |
public spectate(pSettings: Object) source
Spectates another instance with the camera using the passed settings. If the location is over 1000m(pixels) away then the camera will automatically jump to that position no matter if forcePos
is toggled or not.
TODO:
- Allow pSettings.target to also be a coordinate position, this will send the camera to that space and spectate that position.
public zoom(pDestinationLevel: Object, pDuration: number, pEase: Object, pCallback: Function) source
Zooms the camera in via the passed in arguments.
Params:
Name | Type | Attribute | Description |
pDestinationLevel | Object | An object containing the zoom level information. |
|
pDestinationLevel.x | number | The x scale to zoom to. |
|
pDestinationLevel.y | number | The y scale to zoom to. |
|
pDuration | number | The duration of the zoom. |
|
pEase | Object | An object containing the ease information for how the zoom will be performed. |
|
pEase.x | string | The ease to use for the x scale zooming. |
|
pEase.y | string | The ease to use for the y scale zooming. |
|
pCallback | Function | The callback to call after the zoom ends. |
Private Methods
private follow(pMethod: string, pElapsedMS: number) source
Method to follow the target of the camera.
private followLogic(pAxis: string, pPosition: Object, pMethod: string, pElapsedMS: number) source
The logic for following instances via the camera.
private getTrueCenterPos(pInstance: Object): Object source
Returns the true center position by using the x and y position and adding half of the icon's width / height. If no icon is found, we instead use the half of the default tileSize.
Params:
Name | Type | Attribute | Description |
pInstance | Object | The instance to get the true center position of. |
private onShakeEnd() source
private onZoomEnd() source
private reset(pMethod: string) source
Resets the camera based on the method passed.
Params:
Name | Type | Attribute | Description |
pMethod | string | The method to reset. |
private shakeUpdate(pElapsedMS: number) source
The method to update shaking when it is active.
Params:
Name | Type | Attribute | Description |
pElapsedMS | number | The amount of ms that has passed since the last tick. |