geometry-and-math

Reference Phaser 4 geometry classes, intersection tests, and math utilities for game development.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/onemanking/the-operator --skill geometry-and-math-onemanking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: geometry-and-math
Source: https://github.com/onemanking/the-operator/tree/main/.github/skills/geometry-and-math
Command: npx skills add https://github.com/onemanking/the-operator --skill geometry-and-math-onemanking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser 4's geometry and math APIs span dozens of classes and hundreds of functions, making it hard to recall exact signatures, namespaces, and v4-specific changes when writing game code. This Skill provides a structured reference so you can quickly find the right Geom class, intersection test, vector operation, or math helper without digging through source files. ## Core Features & Use Cases - Geometry Classes & Intersections: Covers Circle, Ellipse, Line, Polygon, Rectangle, and Triangle with their static helpers, plus all boolean and point-returning tests under Phaser.Geom.Intersects. - Math Utilities: Documents Vector2, Vector3, Matrix4, angles, distances, interpolation, easing, snapping, fuzzy comparison, and the seeded RandomDataGenerator. - Color Utilities: Explains the Phaser.Display.Color class, HSV/RGB conversion, and color interpolation helpers. - Use Case: While building a collision system, you need to test whether a line of sight crosses a wall rectangle and get the exact intersection point. This Skill points you to Phaser.Geom.Intersects.GetLineToRectangle with the correct argument order and notes the v4 gotcha that Geom objects are data-only and cannot be rendered directly. ## Quick Start Ask how to detect whether a circle overlaps a rectangle in Phaser 4 and get the intersection points.

Frequently Asked Questions about geometry-and-math

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if two shapes overlap in Phaser 4?

Use the boolean tests under Phaser.Geom.Intersects, such as CircleToRectangle or RectangleToRectangle, which return true or false. For actual intersection points, use the Get-prefixed variants like GetCircleToRectangle, which return arrays of Vector2 points.

How do I calculate distance and angle between two points in Phaser?

Use Phaser.Math.Distance.Between(x1, y1, x2, y2) for Euclidean distance and Phaser.Math.Angle.Between(x1, y1, x2, y2) for the angle in radians. For comparisons where the exact value is unneeded, Distance.Squared avoids the costly square root.

Can Phaser Geom objects be rendered directly to the screen?

No, Geom objects like Circle and Rectangle are pure data containers and cannot be added to the display list. To render them, use the Graphics game object or Shape game objects instead.

What replaced the Point class in Phaser 4?

The Point class was removed in Phaser 4. Use Phaser.Math.Vector2 or plain {x, y} objects instead for any code that previously relied on Phaser.Geom.Point.

How do I generate reproducible random numbers in Phaser?

Use Phaser.Math.RandomDataGenerator with a seed, for example new RandomDataGenerator(['level-42']), or the global Phaser.Math.RND seeded via the game config. Its state is serializable via rnd.state() for deterministic save and replay.

Why do my Phaser easing strings behave unexpectedly?

Short easing names like 'Quad' default to the Out variant, meaning Quadratic.Out rather than Quadratic.In. Use full string keys such as 'Quad.easeIn' when you need a specific variant.