Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Example of using palette swapping on a spritesheet in Phaser 3.

NotificationsYou must be signed in to change notification settings

Colbydude/phaser-3-palette-swapping-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Example of using palette swapping on a spritesheet in Phaser 3.

How It Works

This initial idea came from this article:
http://laxvikinggames.blogspot.com/2015/01/build-dynamic-texture-atlas-in-phaser.html

The palette swapping in this example is achieved by taking an image that contains palette data then going through a spritesheet and switching the matching pixels from the original palette to the new palette.

Our "palette data" image is a small image consisting of each unique color we want to replace and their replacements. Each color is a single pixel, and each row represents an individual palette.

Palette Example

We then define a config containing the relevant information for creating the necessary spritesheets and animations after the palette swapping is performed.

varanimConfig={paletteKey:'link-palette',// Palette file we're referencing.paletteNames:['green','red','blue','purple'],// Names for each palette to build out the names for the atlas.spriteSheet:{// Spritesheet we're manipulating.key:'link',frameWidth:32,// NOTE: Potential drawback. All frames are the same size.frameHeight:32},animations:[// Animation data.{key:'walk-down',frameRate:15,startFrame:0,endFrame:9},{key:'walk-left',frameRate:15,startFrame:10,endFrame:19},{key:'walk-up',frameRate:15,startFrame:20,endFrame:29}]};

Once the spritesheets and animations have been built, we can then use them in our game as we need!

Demonstration

About

Example of using palette swapping on a spritesheet in Phaser 3.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp