How to create a textbox blinker?
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? :)
assuming you have a float representing the elapsed time since the last frame, i'd do this:
hth
n.
timer += elapsedtime * somevalue;if (timer > 0.5f) draw blinker;if (timer > 1.0f) timer = 0;
hth
n.
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.
i use it with my blinker (i think theyre called carats) and it runs at approx. 4 blinks per second regardless of frame rate.
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 = 0;
This discards the "overflow", change it to
if ( timer > 1.0f ){ timer -= 1.0f;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement