fix: x/y changes should emit positionChanged

This commit is contained in:
cha0s 2019-03-19 11:02:38 -05:00
parent b4e6ed7c77
commit fc2d873809

View File

@ -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) {} export class Positioned extends decorate(PositionedBase) {}