Camera
Extends:
Static Method Summary
| Static Public Methods | ||
| public static |
|
|
| public static |
getSchema(): {"zoomLevel": *, "center": *} |
|
Constructor Summary
| Public Constructor | ||
| public |
|
|
Member Summary
| Public Members | ||
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
zoomLevel: * |
|
Method Summary
| Public Methods | ||
| public |
addScreenShake(amount: *) |
|
| public |
bindKeys() Binds the arrow keys |
|
| public |
Returns if we can further zoom in |
|
| public |
Returns if we can further zoom out |
|
| public |
Cancels all interactions, that is user interaction and non user interaction |
|
| public |
|
|
| public |
Checks if the mouse event is too close after a touch event and thus should get ignored |
|
| public |
Clamps the camera zoom level within the allowed range |
|
| public |
cleanup() Cleans up all event listeners |
|
| public |
Clears all animations |
|
| public |
Internal touch move handler |
|
| public |
Internal touch start handler |
|
| public |
combinedSingleTouchStopHandler(x: *, y: *) Internal touch stop handler |
|
| public |
deserialize(data: *): * |
|
| public |
findInitialZoom(): * Finds a good initial zoom level |
|
| public |
|
|
| public |
getViewportBottom(): * Returns effective world space viewport bottom |
|
| public |
getViewportHeight(): * Returns effective viewport height |
|
| public |
getViewportLeft(): * Returns effective world space viewport left |
|
| public |
getViewportRight(): * Returns effective world space viewport right |
|
| public |
getViewportTop(): * Returns effective world space viewport top |
|
| public |
getViewportWidth(): * Returns effective viewport width |
|
| public |
Returns the visible world space rect |
|
| public |
Attaches all event listeners |
|
| public |
internalUpdateCentering(now: number, dt: number) Updates the non user interaction centering |
|
| public |
internalUpdateKeyboardForce(now: number, dt: number) Updates the keyboard forces |
|
| public |
internalUpdateMousePanning(now: number, dt: number) Internal screen panning handler |
|
| public |
internalUpdatePanning(now: number, dt: number) Internal pan handler |
|
| public |
internalUpdateShake(now: number, dt: number) Internal shake handler |
|
| public |
internalUpdateZooming(now: number, dt: number) Updates the non user interaction zooming |
|
| public |
Returns if the user is currently interacting with the camera |
|
| public |
Returns if this camera is currently moving by a non-user interaction |
|
| public |
isWorldPointOnScreen(point: Vector): boolean Returns if a point is on screen |
|
| public |
onMouseDown(event: MouseEvent): boolean Mousedown handler |
|
| public |
onMouseMove(event: MouseEvent): boolean Mousemove handler |
|
| public |
Mouseup handler |
|
| public |
onMouseWheel(event: WheelEvent): boolean Mousewheel event |
|
| public |
onTouchEnd(event: TouchEvent=): boolean Touch end and cancel handler |
|
| public |
onTouchMove(event: TouchEvent): boolean Touch move handler |
|
| public |
onTouchStart(event: TouchEvent): boolean Touch start handler |
|
| public |
screenToWorld(screen: Vector): Vector Converts from screen to world space |
|
| public |
setDesiredCenter(center: Vector) Sets a point in world space to focus on |
|
| public |
setDesiredZoom(zoom: number) Sets a desired zoom level |
|
| public |
Sets the camera pan, every frame the camera will move by this amount |
|
| public |
transform(context: CanvasRenderingContext2D) Prepares a context to transform it |
|
| public |
Updates the camera |
|
| public |
Returns if in the next frame the viewport will change |
|
| public |
worldToScreen(world: Vector): Vector Converts from world to screen space |
|
Inherited Summary
| From class BasicSerializableObject | ||
| public static |
|
|
| public static |
getId() |
|
| public static |
Should return the serialization schema |
|
| public static |
|
|
| public |
deserialize(data: any, root: import("./savegame_serializer").GameRoot): string | void |
|
| public |
|
|
Static Public Methods
public static getSchema(): {"zoomLevel": *, "center": *} source
Should return the serialization schema
Override:
BasicSerializableObject#getSchemaReturn:
| {"zoomLevel": *, "center": *} |
Public Constructors
public constructor() source
Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out in non-dev builds
Override:
BasicSerializableObject#constructorPublic Members
public downPreHandler: * source
public eventListenerMouseDown: * source
public eventListenerMouseMove: * source
public eventListenerMouseUp: * source
public eventListenerMousewheel: * source
public eventListenerTouchEnd: * source
public eventListenerTouchMove: * source
public eventListenerTouchStart: * source
public keyboardForce: * source
public lastMovingPosition: * source
public lastMovingPositionLastTick: * source
public lastPinchPositions: * source
public movePreHandler: * source
public numTicksStandingStill: * source
public upPostHandler: * source
public userInteraction: * source
public zoomLevel: * source
Public Methods
public addScreenShake(amount: *) source
Params:
| Name | Type | Attribute | Description |
| amount | * |
public cancelAllInteractions() source
Cancels all interactions, that is user interaction and non user interaction
public centerOnMap() source
public checkPreventDoubleMouse(): boolean source
Checks if the mouse event is too close after a touch event and thus should get ignored
public combinedSingleTouchMoveHandler(x: number, y: number): boolean source
Internal touch move handler
public combinedSingleTouchStopHandler(x: *, y: *) source
Internal touch stop handler
Params:
| Name | Type | Attribute | Description |
| x | * | ||
| y | * |
public deserialize(data: *): * source
Override:
BasicSerializableObject#deserializeParams:
| Name | Type | Attribute | Description |
| data | * |
Return:
| * |
public internalUpdateCentering(now: number, dt: number) source
Updates the non user interaction centering
public internalUpdateZooming(now: number, dt: number) source
Updates the non user interaction zooming
public isCurrentlyInteracting(): boolean source
Returns if the user is currently interacting with the camera
public isCurrentlyMovingToDesiredCenter(): * source
Returns if this camera is currently moving by a non-user interaction
Return:
| * |
public isWorldPointOnScreen(point: Vector): boolean source
Returns if a point is on screen
Params:
| Name | Type | Attribute | Description |
| point | Vector |
public onMouseDown(event: MouseEvent): boolean source
Mousedown handler
Params:
| Name | Type | Attribute | Description |
| event | MouseEvent |
public onMouseMove(event: MouseEvent): boolean source
Mousemove handler
Params:
| Name | Type | Attribute | Description |
| event | MouseEvent |
public onMouseUp(event: MouseEvent=): boolean source
Mouseup handler
Params:
| Name | Type | Attribute | Description |
| event | MouseEvent= |
public onMouseWheel(event: WheelEvent): boolean source
Mousewheel event
Params:
| Name | Type | Attribute | Description |
| event | WheelEvent |
public onTouchEnd(event: TouchEvent=): boolean source
Touch end and cancel handler
Params:
| Name | Type | Attribute | Description |
| event | TouchEvent= |
public onTouchMove(event: TouchEvent): boolean source
Touch move handler
Params:
| Name | Type | Attribute | Description |
| event | TouchEvent |
public onTouchStart(event: TouchEvent): boolean source
Touch start handler
Params:
| Name | Type | Attribute | Description |
| event | TouchEvent |
public screenToWorld(screen: Vector): Vector source
Converts from screen to world space
Params:
| Name | Type | Attribute | Description |
| screen | Vector |
public setDesiredCenter(center: Vector) source
Sets a point in world space to focus on
Params:
| Name | Type | Attribute | Description |
| center | Vector |
public setDesiredZoom(zoom: number) source
Sets a desired zoom level
Params:
| Name | Type | Attribute | Description |
| zoom | number |
public setPan(pan: Vector) source
Sets the camera pan, every frame the camera will move by this amount
Params:
| Name | Type | Attribute | Description |
| pan | Vector |
public transform(context: CanvasRenderingContext2D) source
Prepares a context to transform it
Params:
| Name | Type | Attribute | Description |
| context | CanvasRenderingContext2D |
public update(dt: number) source
Updates the camera
Params:
| Name | Type | Attribute | Description |
| dt | number | Delta time in milliseconds |
