嗨我已经有这个代码:
var refreshIntervalId;
var myImages = [
"walking1.jpg",
"walking2.jpg",
"walking3.jpg",
"walking4.jpg",
"walking5.jpg",
];
var counter = 0;
function switchImage() {
$('#myImage').attr('src', myImages[counter]);
counter += 1;
if (counter == Number($("#counter").val())) {
counter = 0;
clearInterval(refreshIntervalId);
}
}
$(document).ready(function() {
$("#animationBtn").click(function(){
refreshIntervalId = setInterval(switchImage, 50);
});
});
但是现在我想代替图像来播放精灵表,这可能吗?还是我必须更改整个代码,是吗?有人可以帮我吗?