XNA icon cooldown clock effect
But none of the overloads can take an AlphaTestEffect or any Effect it seems... the closest ones seem to be the ones with the SpriteEffects enum
Oops.
Disregard that post. I haven't written XNA code in so long.
You use the blending options in SpriteBatch.Begin(). I believe it's BlendState.AlphaBlend or something similar.
Disregard that post. I haven't written XNA code in so long.
You use the blending options in SpriteBatch.Begin(). I believe it's BlendState.AlphaBlend or something similar.
You can supply an AlphaTestEffect in the SpriteBatch.Begin method. But you need to set it up with a special Projection matrix:
I put a little project here that shows how to use this to make a "clock" effect.
The only downside is that since you're using alpha to control the "angle" at which the "clock" is visible, you can't really use alpha blending. That's fine if you're ok with an opaque background.
Otherwise, you'd need to use a second "alpha texture" to control the angle; that would require writing a custom shader.
// Set up an AlphaTestEffect with a Projection that allows it to be used with SpriteBatch.
Matrix projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
alphaTestEffect = new AlphaTestEffect(GraphicsDevice);
alphaTestEffect.VertexColorEnabled = false;
alphaTestEffect.AlphaFunction = CompareFunction.Greater;
alphaTestEffect.ReferenceAlpha = 0;
alphaTestEffect.World = Matrix.Identity;
alphaTestEffect.View = Matrix.Identity;
alphaTestEffect.Projection = halfPixelOffset * projection;
I put a little project here that shows how to use this to make a "clock" effect.
The only downside is that since you're using alpha to control the "angle" at which the "clock" is visible, you can't really use alpha blending. That's fine if you're ok with an opaque background.
Otherwise, you'd need to use a second "alpha texture" to control the angle; that would require writing a custom shader.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement