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

    Provides methods used for getting and setting the position, scale and rotation of a Game Object.

    interface Transform {
        angle: number;
        rotation: number;
        scale: number;
        scaleX: number;
        scaleY: number;
        x: number;
        y: number;
        setAngle(degrees?: number): this;
        setFixedRotation(): this;
        setPosition(x?: number, y?: number): this;
        setRotation(radians?: number): this;
        setScale(x?: number, y?: number, point?: Math.Vector2): this;
    }

    Implemented by

    Index

    Properties

    angle: number

    Use angle to set or get rotation of the physics body associated to this GameObject. Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally.

    rotation: number

    Use rotation to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians.

    scale: number

    This is a special setter that allows you to set both the horizontal and vertical scale of this Game Object to the same value, at the same time. When reading this value the result returned is (scaleX + scaleY) / 2.

    Use of this property implies you wish the horizontal and vertical scales to be equal to each other. If this isn't the case, use the scaleX or scaleY properties instead.

    scaleX: number

    The horizontal scale of this Game Object.

    scaleY: number

    The vertical scale of this Game Object.

    x: number

    The x position of this Game Object.

    y: number

    The y position of this Game Object.

    Methods

    • Immediately sets the angle of the Body. Angular velocity, position, force etc. are unchanged.

      Parameters

      • Optionaldegrees: number

        The angle to set, in degrees. Default 0.

      Returns this

    • Setting fixed rotation sets the Body inertia to Infinity, which stops it from being able to rotate when forces are applied to it.

      Returns this

    • Sets the position of the physics body along x and y axes. Both the parameters to this function are optional and if not passed any they default to 0. Velocity, angle, force etc. are unchanged.

      Parameters

      • Optionalx: number

        The horizontal position of the body. Default 0.

      • Optionaly: number

        The vertical position of the body. Default x.

      Returns this

    • Immediately sets the angle of the Body. Angular velocity, position, force etc. are unchanged.

      Parameters

      • Optionalradians: number

        The angle of the body, in radians. Default 0.

      Returns this

    • Sets the scale of this Game Object.

      Parameters

      • Optionalx: number

        The horizontal scale of this Game Object. Default 1.

      • Optionaly: number

        The vertical scale of this Game Object. If not set it will use the x value. Default x.

      • Optionalpoint: Math.Vector2

        The point (Vector2) from which scaling will occur.

      Returns this