From fc2d87380932289b3823735c4d92ae250dae05b3 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 19 Mar 2019 11:02:38 -0500 Subject: [PATCH] fix: x/y changes should emit positionChanged --- packages/entity/traits/positioned.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) {}