Files
feuerwerk/tests/viewport/collider-color.test.ts
T
adminandClaude Opus 5.5 e3d47ca9c1
game-maker / gate (push) Successful in 2m59s
game-maker / suite (push) Successful in 9m34s
Show a clickable symbol for colliders in the scene view
Colliders were the only placed part without a symbol in the scene
view. A collider that sits exactly on its sprite was hard to find and
could only be picked by its outline.

- The symbol is the box with four corner handles from the asset
  panel. It stays upright and has a fixed size in world units.
- colliderColor() holds the colour rule of the outline (green,
  trigger colour, red for a shape that collides with nothing). The
  outline and the symbol share it.
- The symbol sits 28 units left of the collider centre. The sprite
  centre stays free for grabbing the sprite, and a rigidbody symbol
  on the same spot is not covered.
- The symbol has its own 26x26 hit area and the outline's handler.
  A click selects the collider and a drag moves it. sceneStack counts
  it as a hit under the pointer.
- The hook __gm.sceneIcon(id) also returns x, y, color, screen and
  clickable.

Findings:
- With the clickable symbol on the sprite centre, four checks in 01
  and 09 dragged the collider instead of the crate. That is why the
  symbol moved beside the centre.

Tests:
- ./check.sh: 153 files, 2237 tests, CHECK EXIT 0 (was 152 / 2234).
- New unit test for colliderColor. svg-icons.test.ts lists the
  collider symbol.
- e2e 41b: 3 new checks (beside the centre without and with a
  rigidbody, click selects the collider).
- e2e 1-16,39-43: ALL PASSED, 635 checks. e2e 41 alone: 20 checks.
- Counter-probes: no symbol fails both placement checks. A symbol
  without hit area fails only the click check.
- Check total 1348 + 3 = 1351, computed, not yet measured by CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:18:10 +02:00

24 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { IDENTITY } from '../../src/core/model/matrix';
import type { PropertyBag } from '../../src/core/model/Properties';
import { colliderShape } from '../../src/core/properties/collider';
import { Theme } from '../../src/ui';
import { colliderColor } from '../../src/viewport/symbols';
const colorOf = (props: PropertyBag) => colliderColor(colliderShape(props, IDENTITY), props);
describe('the colour of a collider in the scene view, outline and icon alike', () => {
it('is the collider colour, the trigger colour for a trigger, red for a shape that collides with nothing', () => {
expect(colorOf({ shape: 'box', width: 40, height: 40 })).toBe(Theme.colors.collider);
expect(colorOf({ shape: 'circle', radius: 20, isTrigger: true })).toBe(Theme.colors.trigger);
const bowtie = [
{ x: -10, y: -10 },
{ x: 10, y: 10 },
{ x: 10, y: -10 },
{ x: -10, y: 10 },
];
expect(colorOf({ shape: 'polygon', points: bowtie })).toBe(Theme.colors.danger);
expect(colorOf({ shape: 'polygon', points: bowtie, isTrigger: true })).toBe(Theme.colors.danger);
});
});