Is there delta Component in phaser 3?

In phaser 2 there was delta component. is there a way to get previous position of sprite? I want to use it to get direction vector on sprite.

There doesn’t seem to be at the moment, although it would be fairly easy to implement. Below is a basic ES6 implementation:

export default class ImageWithDelta extends Phaser.GameObjects.Image
{
    constructor(scene, x, y, texture, frame)
    {
        super(scene, x, y, texture, frame);

        this.deltaX = 0;
        this.deltaY = 0;

        this._prevPosX = x;
        this._prevPosY = y;
    }

    preUpdate()
    {
        this.deltaX = this.x - this._prevPosX;
        this.deltaY = this.y - this._prevPosY;

        this._prevPosX = this.x;
        this._prevPosY = this.y;
    }
}
1 Like