首先创建一个画布
设备的长和宽
图片的信息
定义类来做事
图片资源初始化,
话图片,运动
drawImage
传递一个img对象
位置
创建画布-
var cxt = canvas.getContext('2d')
设备的长和宽
var screenHeight = window.innerHeight;
var screenWidth = window.innerWidth;
图片的信息
var imgSrc= "image//";
var height=;
var width=;
定义类来做事(export default class Main)
export default class Main{
consructor(){ //图片资源出初始化
this.img = new Image();
this.img.src = imgSrc;
}
让图片运动
loop(){
加判断,让他下去以后不至于拉屏
画布下的函数
cxt.drawImage{
图片对象 this.img
位置
图片的大小
}
cxt.drawImage{
图片对象 this.img
位置 -screenHeight+this.top,
图片的大小
}
window.requestAnimationFrame(this.loop.bind(this)) 让图片显示出来
}
}