Skip to content

Particles: the constructor centres the spawn area, say so - #1832

Closed
obiot wants to merge 1 commit into
masterfrom
particles-skill-spawn-area
Closed

obiot wants to merge 1 commit into
masterfrom
particles-skill-spawn-area

Conversation

@obiot

@obiot obiot commented Nov 2, 2026

Copy link
Copy Markdown
Member

Description

The particles skill said a ParticleEmitter's spawn area is measured from the position given to the constructor, and told games to offset by half:

new ParticleEmitter(x - area / 2, y - area / 2, { width: area, height: area });

The constructor actually centres the area on (x, y) (centerOn(x, y)), so following that advice puts every effect up and to the left by half its size. Only pos set after construction is the area's top-left corner.

  • Skill (melonjs-particles-and-trails): pass the centre to the constructor; offset by half only when moving pos later (re-aiming one emitter per burst). Symptom rows for both mistakes.
  • TSDoc: the constructor's x / y and the width setting now say where the area goes.
  • Tests (tests/particle-spawn-area.spec.js): the constructor centres the area, and moving pos places its top-left corner.

No engine behaviour changes, so no changelog entry.

Found while building the Starsweep example: its 3D star dust ended up off to one side.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Checklist

  • I have read the Contributing Guide
  • My code follows the existing code style (pnpm lint passes): Biome checked on the changed files
  • I have tested my changes locally (pnpm test passes): the new spec passes; the rest is untouched
  • I have added tests that cover my changes (if applicable)
  • The build succeeds (pnpm build): left to CI, as only comments changed in src/

Related issues

None.


Generated by Claude Code

The particles skill said the spawn area is measured from the position given
to the constructor, and told games to offset by half. The constructor
centres the area on (x, y), so that advice moved every effect up and left by
half its size. Only `pos` set afterwards is the area's top left corner.

- skill: pass the centre to the constructor; offset by half only when moving
  `pos` later; symptom rows for both mistakes
- TSDoc for the constructor and the `width` setting
- tests pinning both behaviours down

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt
Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

obiot pushed a commit that referenced this pull request Nov 2, 2026
ESLint's arrow-body-style rule failed CI's lint step on the two
one-line `.map((p) => p.pos.x)` callbacks, so the tests never ran
(#1832).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA4xBNBw7cEZzG1bUru

obiot commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Replaced by #1835: this PR's commit, unchanged, plus a fix for the two ESLint arrow-body-style errors in tests/particle-spawn-area.spec.js that failed the lint step. Closing this one in its favour.


Generated by Claude Code

@obiot obiot closed this Nov 2, 2026
obiot added a commit that referenced this pull request Nov 2, 2026
The particles skill said a ParticleEmitter's spawn area is measured from the position given to the constructor, and told games to offset by half. The constructor centres the area on (x, y), so that advice put every effect up and to the left by half its size; only pos set after construction is the area's top-left corner.

- skill: pass the centre to the constructor; offset by half only when moving pos later; symptom rows for both mistakes
- TSDoc: the constructor's x / y and the width setting say where the area goes
- tests: the constructor centres the area, and moving pos places its top-left corner

Replaces #1832, with its lint errors fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants