Community Forum

Make a text blink

Forum Overview >> Scripting

CategoryScripting
Created28.03.2011 21:28


Ludovic Fritz (mrludo40) 28.03.2011 21:29
hello I'm here and I want to know how to flash a text that appears on the screen's my line:

SetTextColor (1, 0, 0, 1);
renderText (0.2, 0.6, 0.15, "-WARNING-");
SetTextColor (0, 30, 0, 1);
renderText (0.09, 0.4, 0.15, "-by-construction");

how to flash just "-WARNING-" thank you
is how I did call for an image at the same time that this action?


Stefan Geiger - GIANTS Software 01.04.2011 09:25
You should call
renderText (0.2, 0.6, 0.15, "-WARNING-");
for maybe 0.5sec, then not call it for another 0.5sec, and then restart.

This you can do by storing an extra blink timer value.

In the "update" function you would do something like this:

self.warningBlinkTimer = self.warningBlinkTimer + dt;

In the :load function you will need something like this:
self.warningBlinkTimer = 0;

and finally the code in the draw function looks like this:

local blinkTime = 500; -- the time between the blinking in ms (eg. 500ms = 0.5sec)
if self.warningBlinkTimer < blinkTime then
renderText (0.2, 0.6, 0.15, "-WARNING-");
elseif self.warningBlinkTimer > 2*blinkTime then
self.self.warningBlinkTimer = self.self.warningBlinkTimer - 2*blinkTime;
end;

Ludovic Fritz (mrludo40) 02.04.2011 02:00
thank you very much


Note: Log in to post. Create a new account here.