小编Har*_*hah的帖子

How to loop a function indefinitely (instead of using conventional for-loop)

I've got a code that will run a set of 20 images, to make it look like an idle sprite is breathing when idle. This runs perfect when its only one loop.

However I can't get it to repeat that loop indefinitely.

Is there a cleaner and faster way to do what i'm doing?

Enclosing that in another for loop doesn't work. It ends in it never loading.

for(let i = 0; i < images.length; i++) {
    window.setTimeout(function () { …
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
68
查看次数

标签 统计

javascript ×1