javascript - HTML5 Canvas flashing text? - Stack Overflow

Does anyone know how to do the following things sequentially on an HTML5 canvas (using javascript).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!

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!

Share edited Aug 7, 2017 at 19:09 Rob 5,2955 gold badges42 silver badges63 bronze badges asked Jan 16, 2012 at 6:56 rshea0rshea0 12.3k9 gold badges30 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7
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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744933154a4601858.html

相关推荐

  • javascript - HTML5 Canvas flashing text? - Stack Overflow

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

    2天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信