phaser - v4.0.0-rc.4
    Preparing search index...

    A Smoothed Key Camera Control.

    This allows you to control the movement and zoom of a camera using the defined keys. Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects.

    var controlConfig = {
    camera: this.cameras.main,
    left: cursors.left,
    right: cursors.right,
    up: cursors.up,
    down: cursors.down,
    zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
    zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
    zoomSpeed: 0.02,
    acceleration: 0.06,
    drag: 0.0005,
    maxSpeed: 1.0
    };

    You must call the update method of this controller every frame.

    Index

    Constructors

    Properties

    accelX: number

    The horizontal acceleration the camera will move.

    accelY: number

    The vertical acceleration the camera will move.

    active: boolean

    A flag controlling if the Controls will update the Camera or not.

    The Camera that this Control will update.

    down: Key

    The Key to be pressed that will move the Camera down.

    dragX: number

    The horizontal drag applied to the camera when it is moving.

    dragY: number

    The vertical drag applied to the camera when it is moving.

    left: Key

    The Key to be pressed that will move the Camera left.

    maxSpeedX: number

    The maximum horizontal speed the camera will move.

    maxSpeedY: number

    The maximum vertical speed the camera will move.

    maxZoom: number

    The largest zoom value the camera will reach when zoomed in.

    minZoom: number

    The smallest zoom value the camera will reach when zoomed out.

    right: Key

    The Key to be pressed that will move the Camera right.

    up: Key

    The Key to be pressed that will move the Camera up.

    zoomIn: Key

    The Key to be pressed that will zoom the Camera in.

    zoomOut: Key

    The Key to be pressed that will zoom the Camera out.

    zoomSpeed: number

    The speed at which the camera will zoom if the zoomIn or zoomOut keys are pressed.

    Methods

    • Starts the Key Control running, providing it has been linked to a camera.

      Returns this

    • Stops this Key Control from running. Call start to start it again.

      Returns this

    • Applies the results of pressing the control keys to the Camera.

      You must call this every step, it is not called automatically.

      Parameters

      • delta: number

        The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

      Returns void