最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML5 Canvas flashing text? - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论