rshea0
rshea0

Reputation: 12249

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!

Upvotes: 4

Views: 3947

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324640

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.

Upvotes: 7

Related Questions