javascript tweenmax做倒计时的方法
<div class="p2_wrap1_wrap1"id="scoreDisplay">30.00</div>
var demo = { score: 30 }, scoreDisplay = document.getElementById("scoreDisplay"); //创建一个tween在20秒内改变score的属性值从0到100. var tween = TweenLite.to(demo, 30, { score: 0, onUpdate: showScore, onComplete:gameOver, ease: Linear.easeNone, }) //在tween update时通过这个function输出. function showScore() { scoreDisplay.innerHTML = demo.score.toFixed(2); } function gameOver(){ alert('游戏结束'); }
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18746.html