phaserjs/phaser/sprites-and-images
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Create and use texture-based Game Objects in Phaser 4: Image and Sprite (this.add.image, this.add.sprite, setTexture, setFrame, setCrop, setDisplaySize, custom classes with scene.add.existing), NineSlice panels, TileSprite scrolling backgrounds (tilePosition, tileScale, tileRotation), Blitter, and pointers to Rope, Mesh2D, Video and SpriteGPULayer. Covers vertexRoundMode for tiles placed edge to edge. Use when adding a player, enemy, pickup, background, parallax layer, button or UI panel, swapping frames, or subclassing Sprite. Corrects v3 habits: setTintFill is gone (use setTint plus setTintMode), this.add.existing(this) inside a class is wrong (use scene.add.existing), TileSprite can't be cropped. Triggers on: Sprite, Image, this.add.sprite, this.add.image, setTexture, setFrame, NineSlice, TileSprite, Blitter, extends Phaser.GameObjects.Sprite.
Install
npx vskill@latest install phaserjs/phaser/sprites-and-imagesSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/sprites-and-images.
Sprites and Images
Image, Sprite and the other texture-based display objects. The shared components (transform, alpha, tint, origin, depth, flip, scroll factor, blend mode) are covered once in game-object-components; this skill covers what is specific to these objects.
Source: src/gameobjects/image/Image.js, src/gameobjects/sprite/Sprite.js, src/gameobjects/components/TextureCrop.js, src/gameobjects/nineslice/NineSlice.js, src/gameobjects/tilesprite/TileSprite.js, src/gameobjects/blitter/. Related: game-object-components, animations, loading-assets, physics-arcade, v4-new-features.
Quick start
Image or Sprite?
They have the same components. A Sprite also has anims (an AnimationState) and is put on the Scene's update list so its preUpdate advances animations. Use Image for anything that never animates by frames.
Textures and frames
- With no frame, the texture's first frame is used (
texture.firstFrame), not the whole atlas. - An unknown texture key silently shows the
__MISSINGtexture. An unknown frame logs a warning and uses the first frame. width/heightare the frame size;displayWidth/displayHeightinclude scale.setSizechanges the internal size (input, physics), not how it looks.setFramealso takes a Frame object. Spritesheet frames are numbers.
Custom classes
Use scene.add.existing(this), not this.add.existing(this): inside the class, this is the Sprite. To make this.add.player(...) work, register a factory with Phaser.GameObjects.GameObjectFactory.register (see game-object-components).
Objects placed edge to edge
With roundPixels on (the game config, or pixelArt: true), the default vertexRoundMode of 'safeAuto' rounds an object's vertices only when it isn't scaled or rotated. Tiles of a background where some are scaled and some aren't then round differently and show thin gaps as the Camera moves. Give all of them the same mode:
Modes: 'off', 'safe', 'safeAuto' (default), 'full', 'fullAuto'. The Auto modes only round when the Camera has roundPixels. See GameObject.vertexRoundMode and docs/Phaser 4 Pixel Art Guide.
Tint
setTint(color) or setTint(tl, tr, bl, br) sets the color; setTintMode(mode) sets how it applies (MULTIPLY, FILL, ADD, SCREEN, OVERLAY, HARD_LIGHT, and MULTIPLY_TWO / MULTIPLY_ADD with setTint2). Tint is WebGL only. The full table is in game-object-components.
NineSlice
A panel or button that resizes without stretching its corners.
- The minimum size is
leftWidth + rightWidthbytopHeight + bottomHeight. Scale it to go smaller. - Slice sizes can come from a Texture Packer (7.1+) atlas, so
this.add.nineslice(x, y, 'ui', 'panel')may be enough. Trimmed frames aren't supported. setSlices(width, height, leftWidth, rightWidth, topHeight, bottomHeight)changes the slices later.- It has one tint color for the whole object (
setTint(color)) andsetTintMode. Its alpha is single (AlphaSingle).
TileSprite
A repeating texture across a fixed-size quad: scrolling backgrounds and parallax.
- Make it the size of the view and scroll
tilePosition. Don't make it the size of the world. - In v4 it works with atlas frames and textures of any size, not just powers of two.
- It has the Texture component, not TextureCrop, so
setCropisn't available.
Blitter
Thousands of simple images from one texture, batched. Bobs have position, frame, flip, alpha, tint and visibility, but no rotation, scale or physics.
Other texture objects
- Video:
this.add.video(x, y, key)afterthis.load.video(key, url), thenvideo.play(). A video from another domain needs CORS to be used as a WebGL texture:this.load.setCORS('anonymous'), from a server that allows it. - Rope (WebGL only):
this.add.rope(x, y, texture, frame, points, horizontal, colors, alphas), a texture bent along a list of points. - Mesh2D (4.2, WebGL only):
this.add.mesh2d(x, y, texture, vertices, indices), textured 2D triangles that batch with sprites. It replaces v3's Mesh for 2D. See v4-new-features. - SpriteGPULayer (WebGL only):
this.add.spriteGPULayer(texture, size)for very large numbers of mostly static sprites. See v4-new-features.
Gotchas
- Alpha or scale of 0 stops rendering. It clears a render flag. Use
setVisible(false)to hide on purpose. - Flip is visual only. It doesn't flip a physics body or hit area.
- `setFrame` resizes the object to the new frame, and applies the frame's pivot if it has one, unless you pass
false, false. This matters when frames differ in size, such as for a physics body or hit area. - `setTintFill` is gone. It only logs an error. Use
setTint(c).setTintMode(Phaser.TintModes.FILL). - Default game size is 1024x768. Position from
this.scale.widthandthis.scale.heightrather than 800x600 habits. - Overriding `preUpdate` on a Sprite without calling
super.preUpdate(time, delta)freezes its animation.
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/sprites-and-images/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/sprites-and-images)