phaserjs/phaser/curves-and-paths
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Phaser 4 curves and paths: Phaser.Curves.Path (this.add.path) with lineTo, splineTo, cubicBezierTo, quadraticBezierTo, ellipseTo, moveTo and closePath; the Line, Spline, CubicBezier, QuadraticBezier and Ellipse curves; getPoint, getPointAt, getSpacedPoints, getTangent and getLength; drawing a path with Graphics; and PathFollower (this.add.follower, startFollow, rotateToPath). Use when moving an enemy or a car along a route, making a winding track, attack patterns, placing objects evenly along a curve, or drawing a smooth curved line. Corrects common mistakes: the end point comes first in cubicBezierTo and quadraticBezierTo, Ellipse angles are degrees, getPoint on a Curve isn't evenly spaced, edited curves keep stale cached lengths. Triggers on: path, curve, spline, bezier, PathFollower, follower, startFollow, getPoint, getSpacedPoints, follow a path.
Install
npx vskill@latest install phaserjs/phaser/curves-and-pathsSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/curves-and-paths.
Curves and paths
Building a Path from curves, reading points along it, drawing it, and moving a sprite along it with a PathFollower.
Source: src/curves/ (one file per curve, Curve.js is the base), src/curves/path/Path.js, src/gameobjects/components/PathFollower.js, src/gameobjects/pathfollower/. Related: tweens, graphics-and-shapes, geometry-and-math.
Quick start
this.add.path(x, y) is the same as new Phaser.Curves.Path(x, y). A Path isn't a Game Object and isn't drawn by itself.
Building a Path
Each method starts the new curve at the end of the last one:
- With numbers,
cubicBezierToandquadraticBezierTotake the end point first. With Vector2s the order is control points then end:cubicBezierTo(cp1, cp2, end),quadraticBezierTo(control, end). They must bePhaser.Math.Vector2instances, not plain objects. splineTo(points)takes Vector2s,{ x, y }objects,[ x, y ]pairs or flat numbers. It adds the path's end point to the start of the array you pass, so don't reuse that array.ellipseToplaces the ellipse so its start angle is on the path's end point. All its angles are degrees.path.add(curve)adds any curve.lineTo,moveTo, and the others return the Path, so they chain.path.toJSON()andnew Phaser.Curves.Path(json)save and load a path.
Curves
| Curve | Constructor | |
|---|---|---|
Phaser.Curves.Line | (p0, p1) Vector2s, or ([ x0, y0, x1, y1 ]) | |
Phaser.Curves.Spline | (points): Vector2s, objects, [ x, y ] pairs or flat numbers. A Catmull-Rom curve through every point. Two or more points. | |
Phaser.Curves.CubicBezier | (start, control1, control2, end) Vector2s, or an array of 8 numbers | |
Phaser.Curves.QuadraticBezier | (start, control, end) Vector2s, or an array of 6 numbers | |
Phaser.Curves.Ellipse | (x, y, xRadius, yRadius = xRadius, startAngle = 0, endAngle = 360, clockwise = false, rotation = 0) or a config object. Angles in degrees. |
On an Ellipse, startAngle, endAngle and angle are degrees, but rotation is radians.
Reading points
- On a Path,
t(0 to 1) is a fraction of the path's length. On a single Curve,getPoint(t)follows the curve's own parameter, which bunches up where the curve bends. Usecurve.getPointAt(u)andcurve.getTangentAt(u)for even spacing. path.getPoint(t)returnsnullfortabove 1.- Pass an
outVector2 in an update loop, so it doesn't make a new one each frame. curve.getDistancePoints(20)gives points 20 pixels apart along a curve.
After editing a curve
Lengths are cached. If you move a curve's points, update the curve, then the path:
Drawing
path.draw(graphics, pointsPerCurve = 32) strokes each curve with the current lineStyle. Each curve is a separate stroke, so a thick line has notches at the corners between curves. To stroke the whole path as one line, with joins at the corners:
getPoints skips the gaps made by moveTo, so this joins across them. See graphics-and-shapes for line joins.
PathFollower
this.add.follower(path, x, y, texture, frame) makes a Sprite which follows a path. It moves itself in preUpdate, so it must be in the Scene, as this.add.follower makes it.
startFollow(duration)takes a number too.- The config makes a number tween with
this.tweens.addCounter, stored asenemy.pathTween. Every tween key works, such asrepeat,yoyo,delayand the callbacks. Callbacks receive that tween, not the follower. - Without
positionOnPath, the follower keeps its distance from the path's start: the whole path is moved by the difference between the follower's position and the path's start. pauseFollow(),resumeFollow(),stopFollow(),isFollowing(),setRotateToPath(true, offsetDegrees).enemy.pathVectoris the follower's position on the path;pathDeltais how far it moved this frame.setPath(newPath)changes the path and starts following it at once, with the last config.setPath(newPath, config)uses a new one.
To move something which isn't a Sprite, such as a Container or Text, tween a value and read the path:
Gotchas
- Bezier argument order. With numbers, the end point comes first:
cubicBezierTo(endX, endY, cp1X, cp1Y, cp2X, cp2Y). - Eases that overshoot break following.
BackandElasticpush the value past 0 or 1, andpath.getPointreturnsnullpast 1. Use eases which stay inside 0 to 1 on a follower. - `startAt` replaces `onStart`. When
startAtis set,startFollowusesonStartitself to seek, so youronStartcallback is lost.startFollowalso writesfrom,to,persistandonStartinto the config object you pass. - Stop a follower before destroying it. The follower doesn't stop its
pathTweenwhen destroyed, so a tween withrepeat: -1keeps running in the TweenManager until the Scene shuts down. CallstopFollow()first. - `moveTo` doesn't draw, but
getPoints()andgetSpacedPoints()skip over the gap, andgetPointcounts it as zero length. - `autoClose` vs `closePath()`.
closePath()adds a line curve back to the start.path.autoClose = trueonly adds the first point to the end ofgetPoints()andgetSpacedPoints().
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/curves-and-paths/SKILL.md
Popularity
- Repository stars
- 39,633
- Repository forks
- 7,130
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/phaserjs/phaser/curves-and-paths)