Tint a collider's area only while the collider itself is selected
A collider filled its area with a faint green in the scene view all the time. It lay over every sprite a collider sits on and made the art look washed out. The outline alone shows where a collider is. The area only matters while one works on that collider. - drawItem takes a selected flag. Only a selected collider is filled, every other one is drawn as its outline. - The fill is stronger than before, alpha 0.3 instead of 0.12, so the selected area is easy to see. The value is COLLIDER_FILL_ALPHA in src/viewport/symbols.ts. - The scene view says what is selected through isSelected. The game view keeps the default and never fills. - Only the collider object itself counts. Selecting its body leaves the area unfilled. Tests: - 2 new unit tests in tests/viewport/collider-color.test.ts read the Pixi instructions: outline only when not selected, fill at 0.3 and outline when selected. - Counter check: with the fill drawn regardless of selection the outline-only test fails. The original is back per cmp. - ./check.sh: 158 files, 2334 tests, CHECK EXIT 0. - e2e 1-17,28-30: no FAIL. e2e 39-43: ALL PASSED, 145 checks. A first run left out 39, which 40 builds on, and failed 8 checks in 40 for the missing tile only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b7e8614a8
commit
495d87847d
4 files changed
+58
-4
No files matched your search
@@ -363,6 +363,11 @@ export class SceneViewport extends FreeViewport {
|
||||
return this.corners.info();
|
||||
}
|
||||
|
||||
protected override isSelected(objectId: string): boolean {
|
||||
const s = this.state.selection;
|
||||
return s?.kind === 'object' && s.objectIds.includes(objectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pixi only says which hit area was pressed; what is really under the pointer is worked out
|
||||
* here, in the order it is drawn (#203): a tilemap's grid is empty where it has no tile, and a
|
||||
|
||||
@@ -137,6 +137,11 @@ export abstract class WorldViewport extends Widget {
|
||||
|
||||
protected onItemPointerDown(_objectId: string, _e: FederatedPointerEvent): void {}
|
||||
|
||||
/** Whether the object itself is selected – a selected collider shows its area filled. */
|
||||
protected isSelected(_objectId: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Screen-space drawing that follows the camera, redrawn after a full redraw and after a pan. */
|
||||
protected drawOnScreen(_items: DrawItem[], _view: View): void {}
|
||||
|
||||
@@ -317,7 +322,13 @@ export abstract class WorldViewport extends Widget {
|
||||
this.syncTilemap(item, onScreen);
|
||||
if (!onScreen) continue;
|
||||
this.visibleCount++;
|
||||
drawItem(node, item, size, view.scale * scaleOf(placementOf(item.type, item.m)));
|
||||
drawItem(
|
||||
node,
|
||||
item,
|
||||
size,
|
||||
view.scale * scaleOf(placementOf(item.type, item.m)),
|
||||
this.isSelected(item.id),
|
||||
);
|
||||
}
|
||||
this.afterItems(items, view);
|
||||
this.drawOnScreen(items, view);
|
||||
|
||||
Reference in new issue
Block a user