XNA icon cooldown clock effect

Started by
12 comments, last by chosendeath 11 years, 6 months ago
In blizzard games, when a spell or item is on cooldown there is a clock effect over the icon. What would be the best way to do this in XNA? I tried using solutions from other posts but they didn't touch directly on XNA, and I couldn't figure out how to implement the solutions.
Advertisement
Given that the icons are normally all of similar sizes/dimensions, I'd guess that it's a semi-transparent animated sprite drawn over the original icon.
I read a way to do it was the alpha mask thing, it seemed like the most efficient way to do it but I couldn't find a way to implement it in XNA.
In XNA you can use SpriteBatch with an AlphaTestEffect. Set the Alpha value to set the threshold above which something is drawn.

If you have a "disc" image with the alpha varying at different angles around the disc, then you could use this to display different "angle ranges" of the disc, so to speak.
How would I do this?
Take 5 vertices and make a square clock. Place vertices at 12, 3, 6 and 9 o'clock and one in the center.

The top and center vertex never moves.

The 3, 6 and 9 o'clock vertices you move in a circle using sin(tx+b) and cos(tx+b), where t is time, x is the scale and b is the phase/offset.
That's not the alpha mask technique though, I want to do what phil said and use an alpha channel texture... but I don't how to use AlphaTestEffect properly with the spritebatch in XNA
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.alphatesteffect_members.aspx
Yes, but how do I use the AlphaTestEffect to actually draw something with the SpriteBatch? Sorry for my noobiness :(
Set up an instance of AlphaTestEffect with the parameters set properly, and then pass it to SpriteBatch.Draw in one of the overloaded functions.

This topic is closed to new replies.

Advertisement