I. Introduction

Before I start this article, I may as well answer the question some of you probably have right now: What is palette swapping?
You've probably seen palette swapping before. Ever played any of the oldMortal Kombats? Noticed how all the ninjas look the same, except for the colors? Well, there's your explanation. Palette swapping is basically switching one color of an object to a different color, i.e. switching red with blue.

II. How to do Palette Swapping in MMF

Step 1: Create an active object (now known as Active1)

Image

Step 2: Go to the event editor. Make up an event. Right click on the box below Active1, go to the Animation submenu and select "Replace Color".

Step 3: Right now you're looking at a table of colors. This table represents the color you want to be replaced. So, if you're objects red, and you want it to be blue, you would click on the red box.

Step 4: Another table of colors pops up. This table represents the color you want to take the previous color's place. If we were using the current example, we would choose blue, because we want the object to be blue and not red.

Step 5: TADA! You're done with your first palette swap in MMF.

However, this is rather weak. If we continue swapping colors this way, we would need dozens of lines of code for multiple colors. Luckily, there's an easier way to make it change to any color you want to in MMF. I will show you how below.

Step 1: Repeat Steps #1 and #2 in the previous example.

Image

Step 2: Right now you're seeing the table of colors. Click on the "Calculate" button.

Image

Step 3: You're in the expression editor. Click on the "Retrieve data from an object" button, right click on Active1, and then select "Get RGB at..."

Step 4: You're given something like
 RGBAt( "Active", > Enter value here <, > Enter value here < )
. The two values are the co-ordinates in Active1. The RGBAt() function will get the color that is on that co-ordinate (so if (1,1) is red, it will get red). The first value is the x-coordinate, and the second value is the y-coordinate. Plug those numbers in.
NOTE: 0,0 is the top left corner.

Step 5: Pick the color you want to replace it with, or you can do another RGBAt() function. Viola! You're finished!
WARNING: Using RGBAt() on an object with the same color in two different places will result in both places having a color change. The same thing will happen with using the regular tables. You must split up your actives to have shirt/sleeves/pants/etc. to have independent colors.

III. What can I use this for?

There are many possibilities in which you can use palette swapping. Probably the most obvious and the best possibility is alternate costums. Alternate costumes give the feel that effort was put into the game, and you can make them by simply swapping colors. With this technique, you don't need to worry about Groups. Plus, it saves space, since it doesn't need to store all those pictures in the .exe!
This technique can also be used in:
(a cool effects without taking a lot of space
(b day to night transitions
(c anything to do with colors

Well, that ends this article. I hope you've learned something.