Skip to content

Instantly share code, notes, and snippets.

@yusugomori
Last active December 15, 2015 03:19
Show Gist options
  • Save yusugomori/5193874 to your computer and use it in GitHub Desktop.
Save yusugomori/5193874 to your computer and use it in GitHub Desktop.
var animate = function($img, imgs, i, refreshRate){
if(i >= imgs.length) return;
setTimeout(function() {
$img.attr('src', imgs[i]); // 画像の切り替え
animate($img, imgs, i+1, refreshRate); // 次のコマ画像へ
}, refreshRate); // 画像の更新間隔
};
var $img = $('#img');
var imgs = [];
for(var i=0; i<100; i++) imgs.push('/path/to/imgs/'+i+'.png'); // コマ画像のパス
var refreshRate = 200;
animate($img, imgs, 0, refreshRate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment