• Advertisement
Sign in to follow this  

How to create a textbox blinker?

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've created a textbox in D3D, and i want to implement a blinker. I need it to blink at a const interval eg once every .5 sec but remember its in the render loop, so it cant be sleep() etc. Suggestions? :)

Share this post


Link to post
Share on other sites
Advertisement
assuming you have a float representing the elapsed time since the last frame, i'd do this:

timer += elapsedtime * somevalue;
if (timer > 0.5f) draw blinker;
if (timer > 1.0f) timer = 0;


hth
n.

Share this post


Link to post
Share on other sites
no. it's the same technique you use to get the camera to move at a fixed speed or make a car move at a fixed speed.
i use it with my blinker (i think theyre called carats) and it runs at approx. 4 blinks per second regardless of frame rate.

Share this post


Link to post
Share on other sites
Tiny nitpick: You've got a small error that might get visible if you show more than one on the screen:

if (timer > 1.0f) timer = 0;

This discards the "overflow", change it to


if ( timer > 1.0f )
{
timer -= 1.0f;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement