phaserjs/phaser/game-object-components
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
The components shared by Phaser 4 Game Objects, and which Game Object has which: Alpha, BlendMode, CleanAlpha, Depth, Flip, Origin, ScrollFactor, Size, Texture, Crop, Tint, Transform, Visible, Mask, Lighting and the rest. Owns the tint modes table (MULTIPLY, FILL, ADD, SCREEN, OVERLAY, HARD_LIGHT, MULTIPLY_TWO, MULTIPLY_ADD, with setTint2) and the component matrix. Also vertexRoundMode and isDestroyed. Use when tinting or flashing a sprite white, fading, ordering with depth, setting an origin, resizing, cropping, pinning a HUD with scroll factor, or checking whether a Game Object has a method. In v4 setTintFill is gone, setTint doesn't change the mode, and setMask is Canvas only. Triggers on: component, mixin, tint, setTintMode, flash white, alpha, blend mode, depth, origin, scroll factor, crop, cleanAlpha, vertexRoundMode.
Install
npx vskill@latest install phaserjs/phaser/game-object-componentsSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/game-object-components.
Game Object components
The mixins that give Game Objects their shared properties and methods, which Game Object has which, and the tint modes.
Source: src/gameobjects/components/, src/gameobjects/GameObject.js, src/renderer/TintModes.js, src/renderer/webgl/shaders/src/ApplyTint.glsl. Related: sprites-and-images, filters-and-postfx, masks-and-stencils, lighting, custom-rendering.
Quick start
How components work
- A component is a plain object of properties and methods.
Phaser.Classcopies it onto the class prototype through theMixinsarray. Getters and setters are copied as accessors. - Every Game Object has
FiltersandRenderSteps, from theGameObjectbase class. The rest depend on the class: see the matrix. - Setters return
this, so they chain. renderFlags(default 15) holds four bits: Visible (1), Alpha (2), Transform (4, the scale) and Texture (8). The object isn't drawn, and takes no input, unless all four are set. Sovisible = false,alpha = 0, ascaleXorscaleYof 0, or a frame with no width or height each turn it off.Phaser.Class.mixin(MyClass, [ Phaser.GameObjects.Components.ElapseTimer ])adds components to your own ES6 class. It works, but isn't in the TypeScript types.
Component matrix
Every Game Object also has Filters and RenderSteps.
| Game Object | Components | |
|---|---|---|
| Image, Sprite, RenderTexture, Stamp, ArcadeImage, ArcadeSprite, MatterImage, MatterSprite | Alpha, BlendMode, Depth, Flip, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Size, TextureCrop, Tint, Transform, Visible. The physics versions add their body components | |
| PathFollower | The Sprite set, plus PathFollower | |
| Text | Alpha, BlendMode, ComputedSize, Crop, Depth, Flip, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Tint, Transform, Visible | |
| BitmapText, DynamicBitmapText | Alpha, BlendMode, Depth, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Texture, Tint, Transform, Visible | |
| TileSprite | Alpha, BlendMode, ComputedSize, Depth, Flip, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Texture, Tint, Transform, Visible | |
| Video | The TileSprite set, with TextureCrop in place of Texture | |
| NineSlice | AlphaSingle, BlendMode, Depth, GetBounds, Mask, Origin, RenderNodes, ScrollFactor, Texture, Transform, Visible. Own tint, tintMode, setTint(color), setTintMode() | |
| Graphics | AlphaSingle, BlendMode, CleanAlpha, Depth, Lighting, Mask, RenderNodes, ScrollFactor, Transform, Visible | |
| Arc, Curve, Ellipse, Grid, IsoBox, IsoTriangle, Line, Polygon, Rectangle, Star, Triangle | AlphaSingle, BlendMode, CleanAlpha, Depth, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Transform, Visible | |
| Container, CustomContext | AlphaSingle, BlendMode, ComputedSize, Depth, Mask, Transform, Visible | |
| Stencil | The Container set, plus StencilModifier | |
| StencilReference | StencilModifier, Visible | |
| Layer | AlphaSingle, BlendMode, Depth, Mask, Visible, and the Structs.List methods | |
| Blitter | Alpha, BlendMode, Depth, Lighting, Mask, RenderNodes, ScrollFactor, Size, Texture, Transform, Visible. Each Bob has setTint(color) | |
| ParticleEmitter | AlphaSingle, BlendMode, Depth, Lighting, Mask, RenderNodes, ScrollFactor, Texture, Transform, Visible. Own tintMode | |
| Rope | AlphaSingle, BlendMode, Depth, Flip, Mask, RenderNodes, ScrollFactor, Size, Texture, Transform, Visible. Own colors, alphas, tintMode | |
| Mesh2D | AlphaSingle, BlendMode, ComputedSize, Depth, Flip, GetBounds, Lighting, Origin, RenderNodes, ScrollFactor, TextureCrop, Transform, Visible. Own tint, tint2, tintMode | |
| SpriteGPULayer | Alpha, BlendMode, Depth, ElapseTimer, Lighting, RenderNodes, TextureCrop, Visible | |
| TilemapLayer, TilemapGPULayer | Alpha, BlendMode, ComputedSize, Depth, ElapseTimer, Flip, GetBounds, Lighting, Mask, Origin, RenderNodes, ScrollFactor, Transform, Visible | |
| Shader, Gradient, Noise, NoiseCell2D/3D/4D, NoiseSimplex2D/3D | BlendMode, ComputedSize, Depth, GetBounds, Origin, ScrollFactor, Transform, Visible | |
| Extern | Alpha, BlendMode, Depth, Flip, Origin, ScrollFactor, Size, Texture, Tint, Transform, Visible | |
| DOMElement | AlphaSingle, BlendMode, Depth, Origin, ScrollFactor, Transform, Visible | |
| PointLight | AlphaSingle, BlendMode, Depth, Mask, RenderNodes, ScrollFactor, Transform, Visible | |
| CaptureFrame | BlendMode, Depth, RenderNodes, Visible | |
| Zone | Depth, GetBounds, Origin, ScrollFactor, Transform, Visible |
Each class lists its mixins in its own file, such as src/gameobjects/sprite/Sprite.js.
Tint
Tint is WebGL only. The tint color and the tint mode are separate: setTint sets colors, setTintMode sets the mode.
| Mode | Value | Result, per pixel | |
|---|---|---|---|
Phaser.TintModes.MULTIPLY | 0 | texture * tint. The default | |
FILL | 1 | tint, keeping the texture's alpha. Use it to flash a sprite | |
ADD | 2 | texture + tint | |
SCREEN | 4 | 1 - (1 - texture) * (1 - tint): lightens | |
OVERLAY | 5 | Darkens dark areas and lightens light ones, by the texture | |
HARD_LIGHT | 6 | Overlay with tint and texture swapped | |
MULTIPLY_TWO (4.2) | 7 | texture * tint + (1 - texture) * tint2: tint colors the light parts, tint2 the dark parts | |
MULTIPLY_ADD (4.3) | 8 | texture * tint + tint2, like a Flash color transform |
There's no mode 3. The two-color modes use the secondary tint, tint2.
| Member | Notes | |
|---|---|---|
setTint(topLeft, topRight, bottomLeft, bottomRight) | Default 0xffffff. One argument sets all four corners. Doesn't change the mode | |
setTint2(topLeft, topRight, bottomLeft, bottomRight) | 4.2. Default 0x000000. Only the two-color modes use it | |
setTintMode(mode) | A Phaser.TintModes value | |
tint | Gets tintTopLeft; setting it sets all four corners | |
tintTopLeft ... tintBottomRight | Default 0xffffff | |
tint2TopLeft ... tint2BottomRight | Default 0x000000. There's no tint2 shortcut on the Tint component | |
tintMode | Default Phaser.TintModes.MULTIPLY | |
clearTint() | Sets the tint to 0xffffff, tint2 to 0x000000 and the mode to MULTIPLY | |
isTinted | true if any corner of tint isn't white, any corner of tint2 isn't black, or the mode isn't MULTIPLY |
Game Objects with their own tint API:
Mesh2D:tint,tint2,tintMode,setTint(color),setTint2(color),setTintMode(),clearTint(), andisTinted(), a method.NineSlice:setTint(color)andsetTintMode(), with notint2.- Tilemaps: each
Tilehastint,tint2andtintMode.TilemapLayer.setTint,setTint2andsetTintModetake a color and a tile area. A TilemapGPULayer can't tint tiles. ParticleEmitterhastintMode; the color comes from the emitter'stintconfig. Particles have notint2.Group.setTint()tints every child.
Components with v4 changes or traps
Alpha and AlphaSingle. Alpha has per-corner alpha: setAlpha(topLeft, topRight, bottomLeft, bottomRight), WebGL only. AlphaSingle has one value. A Container's alpha multiplies into its children.
CleanAlpha (4.3, Graphics and Shapes). Normally each fill and stroke gets the object's alpha, so overlaps show darker. setCleanAlpha() draws the object at alpha 1 to a Camera-sized texture, then fades that texture. It calls enableFilters(), so it's WebGL only. It costs a draw call and a full-Camera pass for each object while its alpha is below 1, so use it only where the overlaps show.
BlendMode. WebGL draws NORMAL, ADD, MULTIPLY, SCREEN and ERASE. Any other Phaser.BlendModes value draws as NORMAL in WebGL; use the Blend filter for them. Canvas has the full set.
Origin. The default is 0.5, 0.5. Text, BitmapText, DynamicBitmapText and tilemap layers default to 0, 0. Graphics, Container, Layer, Blitter, Rope, SpriteGPULayer, CaptureFrame and PointLight have no Origin: they draw from their x and y.
Size and ComputedSize. setSize() changes the size used for bounds, input and physics, not what is drawn. setDisplaySize() and displayWidth / displayHeight change the scale. Size also has setSizeToFrame(). ComputedSize has no frame.
Texture, TextureCrop and Crop. setCrop(x, y, width, height), or setCrop() to clear it, is on objects with TextureCrop, and on Text through Crop. TileSprite, BitmapText, NineSlice and others have plain Texture, so they can't be cropped.
Depth. setDepth() sorts the display list. setToTop(), setToBack(), setAbove(obj) and setBelow(obj) move the object in its list without changing depth, so they only order objects of the same depth.
Transform. z and w aren't draw order; use depth. getWorldTransformMatrix(), getWorldPoint() and getLocalPoint(x, y) include parent Containers.
Mask. Canvas only. In WebGL, setMask() logs a warning and does nothing. See masks-and-stencils.
Lighting. setLighting(true), setSelfShadow(). WebGL only. See lighting.
Filters, RenderSteps and RenderNodes. enableFilters(), then filters.internal / filters.external. See filters-and-postfx. addRenderStep() and setRenderNodeRole() are in custom-rendering.
StencilModifier. The stencil settings of Stencil and StencilReference. See masks-and-stencils.
ElapseTimer. A clock for shader animation on SpriteGPULayer and the tilemap layers: timeElapsed, setTimerPaused(), resetTimer(), setTimerResetPeriod() (default one hour).
PathFollower. See curves-and-paths.
Game Object members
These are on every Game Object, not in a component:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/game-object-components/SKILL.md
Popularity
- Repository stars
- 39,803
- Repository forks
- 7,142
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
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/game-object-components)