Version 2.3.1 - Layer Swapping Changes & Example


I recently released 2.3.1 of Retro Palette Swapper.  There aren't a lot of changes, but the biggest is to Layer Swapping.

Layer Swapping works a bit differently from anything else since there's no "draw event" code for a layer.  Instead, layer swapping utilizes the layer_script_begin and the layer_script_end functions built into GM to set and reset the pal swap.

I've updated the example project with a Layer Swap example.  It utilizes two asset layers and you can swap their palettes independent of one another.  But this functionality is not limited to just asset layers.  It can be used on most layer types: Asset, Tile, Background, and even Instance layers!  This can be really useful for swapping many different objects that all exist on the same layer.

To use a layer swap you need to call
pal_swap_layer_init()
pal_swap_enable_layer("Your Layer Name");

This should be done in a "one and done" event like the Create Event or room start event.  The init function clears out all the data structures that keep track of which layers are being pal swapped, so it's especially important to call that when changing rooms, even if they have the same layer NAMES in them.

Once a layer has been enabled for pal swapping, you just use the layer set function to update it's palette.

pal_swap_set_layer(_pal_sprite, _pal_index, _layer_index, _pal_is_surface)

This should be done before the draw events.  So the step events are ideal for this.

And no need to call pal_swap_reset() as that is built into the layer_script_end function I mentioned earlier.  

This is a feature that hasn't had much use, so give it a try and let me know if you find any issues.


Files

Retro Palette Swapper 2.3.1.yyz --LATEST VERSION 4.6 MB
Dec 30, 2020

Get Retro Palette Swapper - for GameMakerStudio 1 & 2

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.