Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ So your change should look like:
by CSS and wasn't rendered at its natural size (#1096) - @Stanko
- Modified `pos`, `skew` and `scale` components to make operations like
`obj.pos.x += 1` work again (#1109) - @ErikGXDev
- Fixed `AreaComp.area.scale` not being set properly and restored support for
`Vec2` property mutations on `scale` and `offset` (#1121) - @amyspark-ng,
@imaginarny
- Fixed `isKeyDown` and `isButtonDown` getting stuck on game loosing focus
(#1101) - @Stanko

Expand Down
24 changes: 20 additions & 4 deletions src/ecs/components/physics/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ export function area(

let _shape: Shape | null = opt.shape ?? null;
let _scale: Vec2 = opt.scale ? vec2(opt.scale) : vec2(1);
let _scaleProxy: Vec2 | null = null;
let _offset: Vec2 = opt.offset ?? vec2(0);
let _offsetProxy: Vec2 | null = null;
let _cursor: Cursor | null = opt.cursor ?? null;

let _localAreaVersion = -1; // Track local changes in area properties
Expand Down Expand Up @@ -562,18 +564,32 @@ export function area(
return _shape;
},
set scale(value: Vec2) {
_scale = this.scale;
_scale.x = value.x;
_scale.y = value.y;
_localAreaVersion = nextLocalAreaVersion();
},
get scale(): Vec2 {
return _scale;
return (_scaleProxy ??= new Proxy(_scale, {
set(target, prop, value) {
Reflect.set(target, prop, value);
_localAreaVersion = nextLocalAreaVersion();
return true;
},
}));
},
set offset(value: Vec2) {
_offset = value;
_offset.x = value.x;
_offset.y = value.y;
_localAreaVersion = nextLocalAreaVersion();
},
get offset() {
return _offset;
return (_offsetProxy ??= new Proxy(_offset, {
set(target, prop, value) {
Reflect.set(target, prop, value);
_localAreaVersion = nextLocalAreaVersion();
return true;
},
}));
},
set cursor(value: Cursor | null) {
_cursor = value;
Expand Down
Loading