Thursday, January 27, 2011

Shaders

The SimpleShader is the main object used to put an image in a game. A shader is the image a sprite will take on. It will change depending on how the sprite is called.

The main coding for a simple shader goes like so:

simpleShaderWithTexture("X.png", "Y", Z, A);

  • X = filepath of image file used from theme folder, usually a PNG (ex: image.png, if it's in a folder it's foldername/image.png)
  • Y = the name of this shader. Used for identification when calling a sprite (covered later)
  • Z = the order that this sprite appears in on it's layer (discussed later)
  • A = The blend mode.
    • AdditiveBlend = makes things transparent based on darkness (ex: black is entirely transparent, white is fully visible)
    • AlphaBlend = makes nothing transparent except transparent pixels themselves
    • SourcePlusOneMinusSourceAlphaBlend = A shiny version of AlphaBlend (as far as I can tell)
    • noBlend = useless, don't use it.
The RevengeShader is a shader very similar, the only difference is that the image used for this shader changes when entering 8x/16x mode.

revengeShaderWithTextures("X.png", "X-revenge.png", "Y", Z, A);

Here there are two images loaded, one for normal mode, another for revenge mode.


After you have set up a shader, you need to make it show up by setting it up as a sprite.

Theming Basics

Assuming you didn't get here by accident, you probably want to know how to make themes for the popular music rhythm game Tap Tap Revenge. In this blog, I will attempt to cover as much as possible. You should go in order.

Step 1: SimpleShader