pixijs-scene-sprite
pixijs/pixijs-skills
Draw and animate images in PixiJS v8 with Sprite, AnimatedSprite, NineSliceSprite, and TilingSprite.
What is pixijs-scene-sprite?
This skill covers four sprite classes for different image-drawing tasks in PixiJS v8: Sprite for single textures, AnimatedSprite for frame-based animation, NineSliceSprite for resizable UI panels, and TilingSprite for scrolling/repeating backgrounds. Use it when you need to render and position images or animate them through frames.
- Draw single textures with Sprite, supporting anchor, tint, and texture swapping
- Animate characters and objects through frame sequences with AnimatedSprite
- Create resizable UI panels and buttons with NineSliceSprite that preserve corner art
- Render scrolling and repeating backgrounds with TilingSprite using tilePosition
How to install pixijs-scene-sprite
npx skills add https://github.com/pixijs/pixijs-skills --skill pixijs-scene-sprite- Familiarity with pixijs-scene-core-concepts (leaves, transforms, Container)
- Textures loaded via Assets.load() before sprite creation
- PixiJS v8 installed
How to use pixijs-scene-sprite
- 1.Load a texture using Assets.load() before creating a sprite
- 2.Create a Sprite, AnimatedSprite, NineSliceSprite, or TilingSprite with appropriate options (texture, anchor, tint, etc.)
- 3.Set position, scale, rotation, or other transform properties as needed
- 4.For AnimatedSprite, call gotoAndPlay() to start frame animation
- 5.For TilingSprite, animate tilePosition to create scrolling effects
- 6.Add the sprite to a Container or stage using addChild()
Use cases
- Drawing a game character or item sprite at a specific position with rotation and scale
- Animating a character walking cycle from a spritesheet using frame sequences
- Creating a resizable dialog box or button UI panel that scales without stretching borders
- Implementing a parallax scrolling background that repeats infinitely
- Game developers building 2D games with PixiJS
- UI developers creating scalable interface elements
- Graphics programmers working with sprite-based animation
- Web developers building interactive visual applications
pixijs-scene-sprite FAQ
Always use anchor.set(0.5) to center a sprite. Anchor shifts only the draw origin, while pivot shifts both the transform origin and visual position, causing unexpected movement.
Use await Assets.load('path/to/image.png') first, then pass the returned Texture to new Sprite(texture). Do not use Texture.from() in v8; it only reads the cache.
No. Sprite, NineSliceSprite, and TilingSprite all set allowChildren = false. Wrap multiple sprites in a Container to group them.
Sprite draws a single texture. AnimatedSprite is a subclass that cycles through an array of texture frames for frame-based animation. All Sprite properties (anchor, tint, position) apply to AnimatedSprite.
Create a TilingSprite with a repeating texture, then animate its tilePosition property each frame to scroll the pattern.
Full instructions (SKILL.md)
Source of truth, from pixijs/pixijs-skills.
name: pixijs-scene-sprite description: "Use this skill when drawing images in PixiJS v8. Covers Sprite with anchor/tint/texture, AnimatedSprite for frame animation, NineSliceSprite for resizable UI panels, TilingSprite for scrolling/repeating backgrounds. Triggers on: Sprite, AnimatedSprite, NineSliceSprite, TilingSprite, Sprite.from, anchor, tint, tilePosition, animationSpeed, gotoAndPlay, leftWidth, topHeight, constructor options, SpriteOptions, AnimatedSpriteOptions, NineSliceSpriteOptions, TilingSpriteOptions." license: MIT
PixiJS has three sprite classes for different drawing tasks. Sprite is the default image-drawing leaf; NineSliceSprite is a resizable UI-panel variant that preserves corner art; TilingSprite repeats a texture across an area. The AnimatedSprite subclass of Sprite cycles through texture frames for frame-based animation.
Assumes familiarity with pixijs-scene-core-concepts. All sprite classes are leaf nodes; they cannot have children. Wrap multiple sprites in a Container to group them.
Quick Start
const texture = await Assets.load("bunny.png");
const sprite = new Sprite({
texture,
anchor: 0.5,
tint: 0xff8888,
});
sprite.x = app.screen.width / 2;
sprite.y = app.screen.height / 2;
app.stage.addChild(sprite);
Position is set after construction because app.screen.width / 2 depends on the live renderer size. Literal positions can go directly in the options object via x/y (inherited from Container).
Related skills: pixijs-scene-core-concepts (leaves, transforms), pixijs-assets (texture loading), pixijs-scene-particle-container (thousands of sprites), pixijs-performance (spritesheets, batching).
Variants
| Variant | Use when | Trade-offs | Reference |
|---|---|---|---|
Sprite | Draw a single texture at a position | Fixed size = texture size | references/sprite.md |
AnimatedSprite | Frame-based animation from a texture array or spritesheet | Pre-rendered frames only; no tweening | references/animated-sprite.md |
NineSliceSprite | Resizable UI panels, buttons, dialog frames | Border width is fixed; center stretches | references/nineslice-sprite.md |
TilingSprite | Scrolling backgrounds, parallax, repeating patterns | Single texture repeated; tilePosition scrolls | references/tiling-sprite.md |
AnimatedSprite is a subclass of Sprite; all Sprite properties (anchor, tint, position) apply.
Each variant's constructor options are documented in its sub-reference file (references/{variant}.md). All variants also accept the Container options (position, scale, tint, label, filters, zIndex, etc.) — see skills/pixijs-scene-core-concepts/references/constructor-options.md.
When to use what
- "I want to draw a single image at a position" →
Sprite. The default choice for 90% of 2D game and app content. - "I want to animate a character through a series of frames" →
AnimatedSprite. Load a spritesheet via Assets and passsheet.animations['walk']. Seereferences/animated-sprite.md. - "I want a UI button/panel that resizes without stretching the borders" →
NineSliceSprite. Set border widths, then setwidth/height. Seereferences/nineslice-sprite.md. - "I want a scrolling repeating background" →
TilingSprite. AnimatetilePositionto scroll. Seereferences/tiling-sprite.md. - "I want thousands of identical sprites" → Use
ParticleContainerwithParticleinstances (seepixijs-scene-particle-container), not plain sprites. - "I want to draw shapes or paths" → Use
Graphics(seepixijs-scene-graphics), not a sprite.
Quick concepts
Anchor vs pivot
Sprite.anchor is normalized [0, 1] and shifts only the texture draw origin; no position offset. Container.pivot is pixel-space and shifts both the transform origin and the visual position. For centering a sprite, always use anchor.set(0.5).
Loading before creating
Sprite.from(id) only reads the Assets cache; it does not fetch. Always await Assets.load(...) first, or pass the returned Texture directly to new Sprite(texture).
Dynamic textures
Once a texture is loaded, modifying its frame or swapping its source does not automatically notify sprites. Set texture.dynamic = true once, or call sprite['onViewUpdate']() manually after changes.
Common Mistakes
[HIGH] Using Texture.from(url) to load
Wrong:
const texture = Texture.from("https://example.com/image.png");
Correct:
const texture = await Assets.load("https://example.com/image.png");
Texture.from() only reads the cache in v8. Use Assets.load() first; its return value is the texture.
[HIGH] Confusing anchor and pivot
Wrong:
sprite.pivot.set(sprite.width / 2, sprite.height / 2);
Correct:
sprite.anchor.set(0.5);
anchor shifts only the draw origin. pivot shifts the transform origin AND the visual position, causing the sprite to move unexpectedly.
[HIGH] Old NineSlicePlane name
NineSlicePlane was renamed to NineSliceSprite in v8 and switched to an options-object constructor: new NineSliceSprite({ texture, leftWidth, topHeight, rightWidth, bottomHeight }).
[MEDIUM] Adding children to a sprite
Sprite, NineSliceSprite, and TilingSprite all set allowChildren = false. Wrap in a Container to group sprites with other content.
API Reference
Related skills
More from pixijs/pixijs-skills and the wider catalog.

pixijs-scene-text
Render styled text in PixiJS v8 with Text, BitmapText, HTMLText, and split variants for animation.

pixijs-ticker
Control PixiJS v8 render loop with frame-rate-independent animation and priority-based callbacks.

pixijs
Router skill for PixiJS v8—directs to specialized sub-skills for rendering, scene objects, assets, and advanced graphics.

pixijs-accessibility
Add screen reader and keyboard navigation to PixiJS v8 apps via AccessibilitySystem.

mysql
Plan and review MySQL/InnoDB schema, indexing, query tuning, transactions, and operations.

neki
Overview and information about Neki, the sharded Postgres product by PlanetScale. Load when working with Neki-related tasks and the need to scale or shard postgres. Load when facing Postgres scaling or sharding issues.