Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseCamera

obsolete

BaseCamera renamed to Camera. Use Camera instead

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected _follow

_follow: Actor

Protected _isShaking

_isShaking: boolean = false

Protected _isZooming

_isZooming: boolean = false

ax

ax: number = 0

ay

ay: number = 0

az

az: number = 0

dx

dx: number = 0

dy

dy: number = 0

dz

dz: number = 0

eventDispatcher

eventDispatcher: EventDispatcher

Direct access to the game object event dispatcher.

rotation

rotation: number = 0

rx

rx: number = 0

strategy

strategy: StrategyContainer = new StrategyContainer(this)

z

z: number = 1

Accessors

isInitialized

  • get isInitialized(): boolean

pos

vel

viewport

x

  • get x(): number
  • set x(value: number): void
  • Get the camera's x position

    Returns number

  • Set the camera's x position (cannot be set when following an Actor or when moving)

    Parameters

    • value: number

    Returns void

y

  • get y(): number
  • set y(value: number): void
  • Get the camera's y position

    Returns number

  • Set the camera's y position (cannot be set when following an Actor or when moving)

    Parameters

    • value: number

    Returns void

Methods

_initialize

  • _initialize(_engine: Engine): void

_postupdate

  • _postupdate(engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal preupdate handler for <a href="camera_.basecamera.html#onpostupdate">onPostUpdate lifecycle event

    internal

    Parameters

    • engine: Engine
    • delta: number

    Returns void

_preupdate

  • _preupdate(engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal preupdate handler for <a href="camera_.basecamera.html#onpreupdate">onPreUpdate lifecycle event

    internal

    Parameters

    • engine: Engine
    • delta: number

    Returns void

addStrategy

clearAllStrategies

  • clearAllStrategies(): void

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D): void

draw

  • draw(ctx: CanvasRenderingContext2D): void
  • Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera

    Parameters

    • ctx: CanvasRenderingContext2D

      Canvas context to apply transformations

    Returns void

emit

  • emit(eventName: string, eventObject?: GameEvent<any>): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • Optional eventObject: GameEvent<any>

      Data associated with this event

    Returns void

getFocus

  • Returns the focal point of the camera, a new point giving the x and y position of the camera

    Returns Vector

getZoom

  • getZoom(): number

move

  • This moves the camera focal point to the specified position using specified easing function. Cannot move when following an Actor.

    Parameters

    • pos: Vector

      The target position to move to

    • duration: number

      The duration in milliseconds the move should last

    • Default value easingFn: EasingFunction = EasingFunctions.EaseInOutCubic

    Returns IPromise<Vector>

    A Promise that resolves when movement is finished, including if it's interrupted. The Promise value is the Vector of the target position. It will be rejected if a move cannot be made.

off

  • off(eventName: "initialize", handler?: function): void
  • off(eventName: "preupdate", handler?: function): void
  • off(eventName: "postupdate", handler?: function): void
  • off(eventName: string, handler: function): void

on

  • on(eventName: "initialize", handler: function): void
  • on(eventName: "preupdate", handler: function): void
  • on(eventName: "postupdate", handler: function): void

onInitialize

  • onInitialize(_engine: Engine): void

onPostUpdate

  • onPostUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPostUpdate is called directly after a scene is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

onPreUpdate

  • onPreUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before a scene is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

once

  • once(eventName: "initialize", handler: function): void
  • once(eventName: "preupdate", handler: function): void
  • once(eventName: "postupdate", handler: function): void
  • once(eventName: string, handler: function): void

removeStrategy

shake

  • shake(magnitudeX: number, magnitudeY: number, duration: number): void
  • Sets the camera to shake at the specified magnitudes for the specified duration

    Parameters

    • magnitudeX: number

      The x magnitude of the shake

    • magnitudeY: number

      The y magnitude of the shake

    • duration: number

      The duration of the shake in milliseconds

    Returns void

update

  • update(_engine: Engine, delta: number): void

zoom

  • Zooms the camera in or out by the specified scale over the specified duration. If no duration is specified, it take effect immediately.

    Parameters

    • scale: number

      The scale of the zoom

    • Default value duration: number = 0

      The duration of the zoom in milliseconds

    • Default value easingFn: EasingFunction = EasingFunctions.EaseInOutCubic

    Returns Promise<boolean>

Static extend

  • extend(methods: any): any
  • You may wish to extend native Excalibur functionality in vanilla Javascript. Any method on a class inheriting Class may be extended to support additional functionality. In the example below we create a new type called MyActor.

    var MyActor = Actor.extend({
    
       constructor: function() {
          this.newprop = 'something';
          Actor.apply(this, arguments);
       },
    
       update: function(engine, delta) {
          // Implement custom update
          // Call super constructor update
          Actor.prototype.update.call(this, engine, delta);
    
          console.log("Something cool!");
       }
    });
    
    var myActor = new MyActor(100, 100, 100, 100, Color.Azure);

    In TypeScript, you only need to use the extends syntax, you do not need to use this method of extension.

    Parameters

    • methods: any

      A JSON object contain any methods/properties you want to extend

    Returns any