Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Canvas flashing text?

Does anyone know how to do the following things sequentially on an HTML5 canvas (using javascript).

  1. Text appears (I already know how to do this :P)
  2. Text flashes several times at one second intervals
  3. Text disappears after 5 seconds (or whenever)

The reason I find this so hard to do, is because there is no way to create a pause in a script. Any help would be greatly appreciated!

like image 558
rshea0 Avatar asked Nov 01 '25 06:11

rshea0


1 Answers

function flashyText() {
    var count = 10,
        timer = setInterval(function() {
            count--;
            if( count%2 == 1) {
                // draw the text
            }
            else {
                // don't draw it (ie. clear it off)
            }
            if( count == 0) clearInterval(timer);
        },1000);
}

Something like that.

like image 115
Niet the Dark Absol Avatar answered Nov 03 '25 21:11

Niet the Dark Absol