Re: Flashing a sprite

You could do something like this:

public class Animation
private float timeSinceLastFrame = 0f;

... cut to the chase ...
public void Update(float timeElapsed)
timeSinceLastFrame += timeElapsed;
if(timeSinceLastFrame >= frames[frameIndex].timeToDisplay)
timeSinceLastFrame = 0;
// Optionally, you can loop back to the beginning by checking if
you've reached the end of the animation, in which case frameIndex would go
back to Zero.

public class Frame
private float timeToDisplay = 0;

Somethingl ike this would work for small animations.

"Daniel" wrote:

Hey ZMan

can you explain why

if (gametime % 2.0 == 0)

that would work? isn't that just dividing by 2 and if the answer is equal to
show time? I guess the 2 would be my amount of seconds....but after gametime
goes over 2 seconds it would stop?

Really confused by that example sorry.....appreciate the help tho

"ZMan" <zman@xxxxxxxxxxxxxx> wrote in message
Maxamor is correct. For both #1 and #2 you should not base anything on
frametime (unless you can atarget specific hardware and lock the

Use the stopwatch class in system.diagnostics to give you a time in

Then do something like

if (gametime % 2.0 == 0)
show sprite

Zman - News and information for Managed DirectX

"Maxamor" <Maxamor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
As far as animation goes, I recommend not making it based off of "x
amount of
frames display frame 0, x amount of frames display frame 1" etc...

The reason behind this is that each frame may not be the same amount of
depending on which computer your program is running on. This means the
animation may look great on your pc, but if it runs faster on someone
the animation would go faster too, possibly too fast.

Make the animation time-based.

That way, each frame can have an amount of time that it displays itself
before it lets the next frame be drawn.

Then, you could just make a 2-frame animation for your flashing sprite.
is completely invisible, and the other is completely visible and have
both display for 500ms or something. Then all you have to do is loop the

"Daniel" wrote:


Any one now a good tutorial or can help me onhow to make a flashing
I want to make a flashing arrow.

I have some ideas:

1) lower and increase the alpha levels per frame
2) have it non rendered and then rendered after x many frames..

My problem is for option 2...and 1 for that matter, how do i get it to
at a pace i want?

Is this kind of solution mental? To make a class for the flashing sprite
that i call say SpriteFlasher.

Then in that class have a var for how many frames to allow to pass until
showing the sprite, and another var for howmany frames it should remain
visible for.

Then i could create an instance and pass in the frames passed on every