男(
小飞机图片无法加载为何我复制粘贴的开发文档代码都加载不出来我的飞机?只能显示矩形下落 我已经把图片放在跟game.js同一个目录下了,看到飞机只是闪了一下,就没了,矩形一直下落 const canvas = wx.createCanvas() const context = canvas.getContext('2d') // 创建一个 2d context context.fillStyle = '#1aad19' // 矩形颜色 // context.fillRect(0, 0, 100, 100) // 矩形左上角顶点为(0, 0),右下角顶点为(100, 100) // context.fillRect(canvas.width / 2 - 50, 0, 100, 100) const { windowWidth, windowHeight } = wx.getSystemInfoSync() function drawRect(x, y) { context.clearRect(0, 0, windowWidth, windowHeight) context.fillRect(x, y, 100, 100) } drawRect(canvas.width / 2 - 50, 0) const rectX = canvas.width / 2 - 50 let rectY = 0 setInterval(function () { drawRect(rectX, rectY++) }, 16) const image = wx.createImage() const imgX = canvas.width / 2 - 50 let imgY = 500 image.onload = function () { context.drawImage(image, imgX, imgY) } image.src = "../hero.png"
2020-05-21