飞机示例代码有一个基本功能上的bug
https://developers.weixin.qq.com/minigame/dev/guide/ 示例代码中封装的绘制矩形的函数,在执行前会清空整个屏幕,从而导致后面代码中下方的飞机被清除。 const { windowWidth, windowHeight } = wx.getSystemInfoSync()
function drawRect(x, y) {
context.clearRect(0, 0, windowWidth, windowHeight)
context.fillRect(x, y, 100, 100)
}
我改成了这样,仅供参考: const { windowWidth, windowHeight } = wx.getSystemInfoSync() function drawRect(x, y) { //context.clearRect(0, 0, windowWidth, windowHeight) context.clearRect(rectX, 0, 100, 100 + rectY) context.fillRect(x, y, 100, 100) }