diff --git a/packages/entity/traits/positioned.js b/packages/entity/traits/positioned.js index cb6dc46..ba84b7c 100644 --- a/packages/entity/traits/positioned.js +++ b/packages/entity/traits/positioned.js @@ -37,6 +37,25 @@ class PositionedBase extends Trait { } } + listeners() { + return { + xChanged: (x, oldX) => { + this.entity.emit( + 'positionChanged', + this.entity.position, + [oldX, this.entity.y] + ); + }, + yChanged: (y, oldY) => { + this.entity.emit( + 'positionChanged', + this.entity.position, + [this.entity.x, oldY] + ); + }, + } + } + } export class Positioned extends decorate(PositionedBase) {}