keyFrames在前端页面添加序列帧动画

var aofeikeyFrames;
function keyFrames(id, img, width, height, keyFrames){
	keyFrames = new CanvasKeyFrames(document.querySelector(id), 'sprite', img, {
		fps:10,
		imgWidth:width,
		imgHeight:height,
		width:50,
		height:50
	});
	keyFrames.play();
}

var aofei = new Image();
	aofei.src = 'img/en_aofei.png';
	$(".aofei").css("width", '7.5rem');
	$(".aofei").css("height", '1.8975rem');
	$(".aofei").css("margin-right", '-9.5rem');
	$(".aofei").css("margin-bottom", '-7rem');
	aofei.onload = function(){
		aofei.onload = null;
		keyFrames(".aofei", aofei, 373, 120, aofeikeyFrames);//div对象  对应图片   序列帧动画宽度  序列帧动画高度 指定序列帧对象
    }

猜你喜欢

转载自blog.csdn.net/qq_22266149/article/details/89147194