There's not much more to say;
- Alpha masking uses a mask (a single bit image) to set transparency
- Alpha transparency uses the alpha calue of the sprite colour to set transparency.
How about if you can see the difference;
// Set up screen and test Sprite
thisWidth = getDeviceWidth()
thisHeight = getDeviceHeight()
setVirtualResolution(thisWidth,thisHeight)
spinsprite = createSprite(0)
setSpriteSize( spinsprite , Largest( thisWidth,thisHeight ) , 20 )
setSpritePositionByOffset( spinsprite , thisWidth * 0.5 , thisHeight * 0.5)
setSpriteDepth( spinsprite , 100 )
// Load Image - left half is picture, right is mask
testImage = loadImage( "test.png" )
imgWidth = getImageWidth( testImage ) * 0.5
imgHeight = getImageHeight( testImage )
// Copy image from left side to image for alpha transparency
transImage = copyimage( testImage , 0 , 0 , imgWidth , imgHeight )
// Copy image from left side to image for alpha Mask
maskImage = copyimage( testImage , 0 , 0 , imgWidth , imgHeight )
// Copy Alpha Mask from right Side
tempMask = copyimage( testImage , imgWidth , 0 , imgWidth , imgHeight )
// Set Mask on Masked Image
setImageMask( maskImage , tempMask , 4 , 1 , 0 , 0 )
// Delete Images no longer needed
deleteimage( tempMask )
deleteimage( testImage )
// Create Sprite used for alpha transparency
transSprite = createSprite( transImage )
setSpriteSize( transSprite , thisWidth * 0.5 , thisHeight * 0.5 )
// Set Transparency to 50%
setSpriteColorAlpha( transSprite , 127 )
// Create Sprite used for alpha Mask
maskSprite = createSprite( maskImage )
setSpriteSize( transSprite , thisWidth * 0.5 , thisHeight * 0.5 )
setSpritePosition( transSprite , thisWidth * 0.5 , thisHeight * 0.5 )
do
setSpriteAngle( spinSprite , timer() * 100 )
sync()
loop
function Largest( intA , intB )
if intA > intB then exitfunction intA
endfunction intB
This code takes the attached image and splits it in half. It copies the left half to two images. Each image is used on a sprite.
It copies the right side and uses the red colour channel (1) to form the alpha channel (4) of one of the images.
It then displays two sprites which use these images (alpha masked top left, alpha transparency bottom right). The sprite using the alpha mask image is left as is. the other is set to 50% transparency (127 in its colouralpha)
In the main loop it simply rotates a blank sprite behind both of these.
This is the test image