用 Canvas 画出一个扇形并进行旋转,模拟器上没问题,真机上出现问题?求助
发布于 7 年前 作者 kangxiulan 6864 次浏览 来自 问答
//index.js
var windowWidth = 0
var cx = 0,
  cy = 0,
  radius = 0

startAni() {
// cx cy 在调用之前已经复制为 圆心的 x,y
var center = cx + 'px ' + cy + 'px'
console.log(center)
var ani = wx.createAnimation({
  duration: 800,
  transformOrigin: center
})

var a = 0
let that = this
var intervalId = setInterval(function() {
  console.log('a: ', ++a)
  ani.rotate(180 * a).step()
  that.setData({
    animationData: ani.export()
  })
  if (a == 30) {
    that.stopAni(intervalId)
  }
}, 800)
},

模拟器执行视频地址:https://monster-image-backup.oss-cn-shanghai.aliyuncs.com/share/moniqi.mp4

真机执行视频:https://monster-image-backup.oss-cn-shanghai.aliyuncs.com/share/ubji.mp4

回到顶部