Created
August 14, 2010 04:32
-
-
Save geoffb/523975 to your computer and use it in GitHub Desktop.
A simple example of changing the alpha of a sprite.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctx.save(); | |
// 50% opacity | |
// Anything drawn after this call (but before call .restore) will be drawn at 50% opacity | |
ctx.globalAlpha = 0.5; | |
ctx.drawImage( | |
spriteSourceImage, | |
sourceX, sourceY, sourceWidth, sourceHeight, | |
destX, destY, destWidth, destHeight | |
); | |
ctx.restore(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment