Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -67,6 +67,9 @@ So your change should look like:
`obj.pos.x += 1` work again (#1109) - @ErikGXDev
- Fixed `scale`, `skew`, and `rotate` component transforms not being applied on
the initial `GameObjRaw.use()` call (e.g. `obj.use(scale(2))`) - @mflerackers
- 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