feat: track position change
This commit is contained in:
parent
701623ea31
commit
3b55648f60
|
@ -28,7 +28,13 @@ class PositionedBase extends Trait {
|
|||
}
|
||||
|
||||
set position([x, y]) {
|
||||
this.state = this.state.merge({x, y});
|
||||
const positionChanged = x !== entity.x || y !== entity.y;
|
||||
const lastPosition = entity.position;
|
||||
this.entity.x = x;
|
||||
this.entity.y = y;
|
||||
if (positionChanged) {
|
||||
this.entity.emit('positionChanged', entity.position, lastPosition);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user