geometry-and-math

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

Updated May 7, 2021
One-click install
npx skills add https://github.com/travispwingo/travispwingo.github.io --skill geometry-and-math-travispwingo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: geometry-and-math
Source: https://github.com/travispwingo/travispwingo.github.io/tree/main/mario/docs/skills/geometry-and-math
Command: npx skills add https://github.com/travispwingo/travispwingo.github.io --skill geometry-and-math-travispwingo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Phaser 4 developers need accurate API knowledge for geometry objects, intersection tests, vectors, matrices, easing, and random number generation, and this Skill provides a complete reference so the AI writes correct Phaser math code without guessing method names or signatures. ## Core Features & Use Cases - Geometry Classes: Covers Circle, Ellipse, Line, Polygon, Rectangle, and Triangle with constructors, properties, static helpers, and containment tests. - Intersection Tests: Documents all Phaser.Geom.Intersects boolean checks and Get* functions that return intersection points as Vector2 arrays. - Math Utilities: Includes Vector2, Vector3, Matrix4, angles, distances, interpolation, easing, snapping, fuzzy comparison, and the seeded RandomDataGenerator. - Use Case: When building a game mechanic like checking whether a bullet circle overlaps an enemy rectangle, the AI can immediately use Phaser.Geom.Intersects.CircleToRectangle with the correct signature and gotchas in mind. ## Quick Start Use the geometry-and-math skill to write Phaser 4 code that checks whether a circle at position (400, 300) with radius 50 intersects a rectangle and calculate the angle between two 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 collision between a circle and rectangle in Phaser 4?▼

Use Phaser.Geom.Intersects.CircleToRectangle(circle, rect), which returns a boolean indicating overlap. For the actual intersection points, use Phaser.Geom.Intersects.GetCircleToRectangle, which returns a Vector2 array.

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 only, Distance.Squared avoids the costly square root.

Can Phaser Geom objects be rendered directly to the screen?▼

No, Geom objects are pure data containers and cannot be added to the display list. To render them, use the Graphics game object or Shape game objects, which are covered by the graphics-and-shapes skill.

Does Phaser 4 still have the Point class?▼

No, the Point class was removed in Phaser 4. Use Phaser.Math.Vector2 or plain {x, y} objects instead for representing 2D positions.

How do I generate reproducible random numbers in Phaser?▼

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

Why do Vector2 operations change my original vector in Phaser?▼

Vector2 methods mutate in place and return this for chaining. Call .clone() first when you need to preserve the original, for example const result = v.clone().add(other).