All Projects → Colbydude → phaser-3-palette-swapping-example

Colbydude / phaser-3-palette-swapping-example

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

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to phaser-3-palette-swapping-example

Opensc2k
OpenSC2K - An Open Source remake of Sim City 2000 by Maxis
Stars: ✭ 4,753 (+14753.13%)
Mutual labels:  phaser, phaserjs, phaser3
infinite-jumper-template-phaser3
Starting point template source code from Infinite Jumper in Phaser 3 in Modern JavaScript book.
Stars: ✭ 46 (+43.75%)
Mutual labels:  phaserjs, phaser3, phaser3-example
Phaser
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
Stars: ✭ 30,918 (+96518.75%)
Mutual labels:  phaser, phaserjs, html5-game-development
phaser-3-vsc-typescript-nodejs
Template for a new Phaser 3 project with Visual Studio Code, TypeScript, and Node.js.
Stars: ✭ 18 (-43.75%)
Mutual labels:  phaserjs, html5-game-development, phaser3
Cavemen-GGJ2019
A multiplayer survival game developed during Global Game Jam 2019.
Stars: ✭ 21 (-34.37%)
Mutual labels:  phaser, html5-game-development, phaser3
phaser3-faq
A guide to Phaser 3
Stars: ✭ 69 (+115.63%)
Mutual labels:  phaser, phaser3
phaser-ui-comps
Phaser 3 UI Components built by Adobe Animate
Stars: ✭ 60 (+87.5%)
Mutual labels:  phaser, phaser3
phaser3-simple-rpg
A simple Phaser3 RPG using Typescript ⚔️
Stars: ✭ 80 (+150%)
Mutual labels:  phaser, phaser3
phaser-plugin-game-scale
Scale or resize the game canvas. Phaser v3.15 only
Stars: ✭ 35 (+9.38%)
Mutual labels:  phaser, phaser3
phaser3-typescript-starter-kit
This repository contains the code necessary to start making a game in Phaser 3 using TypeScript.
Stars: ✭ 94 (+193.75%)
Mutual labels:  phaser, phaser3
craft
Phaser Library with utility chainable functions
Stars: ✭ 27 (-15.62%)
Mutual labels:  phaser, phaserjs
ionic4-phaser3-template
Ionic 4 and phaser 3 template
Stars: ✭ 19 (-40.62%)
Mutual labels:  phaser3, phaser3-example
phaser-particle-editor-plugin
This plugin creates particles based on JSON data generated by Phaser Particle Editor
Stars: ✭ 28 (-12.5%)
Mutual labels:  phaser, phaserjs
badassquest
RPG / GTA-style game engine built on top of Google Maps Javascript APIs
Stars: ✭ 26 (-18.75%)
Mutual labels:  phaser, html5-game-development
phaser3-typescript-template
A Phaser 3 TypeScript Template
Stars: ✭ 30 (-6.25%)
Mutual labels:  phaserjs, phaser3
ts-phaser-bomb-game
Bomberman clone using websockets and phaser 3
Stars: ✭ 18 (-43.75%)
Mutual labels:  phaser, phaser3
mmo-arch
Base Architecture for creating scalable games using microservices through Angular, Phaser, NestJS, NATS, and MySQL
Stars: ✭ 25 (-21.87%)
Mutual labels:  phaser, phaser3
phaser-jam-template
A Phaser Template to kick off your Game Jam with everything you need. Typescript, code quality, building for itch, various input methods, examples, bootloader, preloader, main game, end screen, credits screen and license screen.
Stars: ✭ 18 (-43.75%)
Mutual labels:  phaser, phaser3
Phaser Ui Tools
Functions for creating a UI in Phaser. Rows, columns, viewports, scrollbars, stuff like that.
Stars: ✭ 187 (+484.38%)
Mutual labels:  phaser, phaserjs
dungeonz
Everything for the game Rogueworld.
Stars: ✭ 88 (+175%)
Mutual labels:  phaser, phaserjs

Phaser 3 Palette Swapping Example

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.

var animConfig = {
    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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].