鍍金池/ 問答/網絡安全/ Phaser循環(huán)間隔時間怎么寫一個越來越快的

Phaser循環(huán)間隔時間怎么寫一個越來越快的

var appleTimer = game.time.create(true);
appleTimer.loop(1000, function() {
})
我怎么能讓loop循環(huán)時間不是固定的1000,而是隨著時間慢慢變快了呢

回答
編輯回答
傻叼

可以用定時遞歸,例如:

var timeout = 1000;
function test() {

setTimeout(function() {
    // do some thing
    if (要繼續(xù)定時執(zhí)行) {
        test();
    } else {
        // 結束了
    }        
}, timeout);
timeout = timeout <= 200 ? 200 : timeout - 50;

}

// 讓它跑起來
test();

2018年6月7日 17:21