var animation = wx.createAnimation({
duration: 20000,
timingFunction: 'linear',
})
audioPlay: function (e) {
// 在标签页添加 data-*** 可以通过e.currentTarget.dataset.*** 取值
this.audioCtx.play()
this.setData({
courseImg: '../../images/pause.png'
})
this.setData({
temp1: true
})
this.setData({
temp2: false
})
var that = this
setInterval(function(){
that.animation = animation
animation.rotate(360).step()
that.setData({
animationData: animation.export()
})
},1000)
},
这是 代码,但是动画只会播放一次,不知道如何去循环播放,请教一下大神
真难用,还不入原声的animateApi
<view animation="{{animationRec}}" class="rec"></view>
// animation/translateX/translateX.js Page({ data: { animationRec: {}, }, onLoad: function (options) {}, onShow() { var animation = wx.createAnimation({ duration: 1000, timingFunction: "ease", }); this.animation = animation; setInterval( function () { this.startMove(); }.bind(this), 1000 ); }, startMove() { // 先旋转同时放大,然后平移 this.animation.translate(200, 0).step({ duration: 1000 }); this.animation.translate(0, 0).step({ duration: 1000 }); this.setData({ animationRec: this.animation.export(), }); }, });
setinterval里数据执行完要处理(比如++),这样每次都执行新的动画
楼主最现在解决了吗,请教一下
先放着干别的,到时候弄好了再来回复你,谢谢了
这就涉及到我的知识盲区了 楼主你再多试试吧
}, loopValue)
},playCD:function(){
var animation = wx.createAnimation({
duration: 20000,
timingFunction: 'linear',
})
var that = this
console.info('开始调用了')
var timer = setInterval(function () {
this.animation = animation
animation.rotate(360).step()
that.setData({
animationData: animation.export()
})
}, 1000)
setTimeout(function (){
clearInterval(timer)
},1000)
},
已经放到了playCD里,还是不行
那你这个setInterval应该把整个动画都要把括进去了,包括创建动画,而不仅仅只是执行动画这一块了 楼主你再试试
还是只播放了一次,看API写的 animationData: animation.export()
export
方法每次调用后会清掉之前的动画操作试试这样的
audioPlay: function (e) {
// 在标签页添加 data-*** 可以通过e.currentTarget.dataset.*** 取值
this.audioCtx.play()
this.setData({
courseImg: '../../images/pause.png', temp1: true, temp2: false
})
var that = this
setInterval(function(){
that.playCD()
},2000)
},
playCD:function(){
var that = this;
console.info('开始调用了')
var timer=setInterval(function () {
that.animation = animation
animation.rotate(360).step()
that.setData({
animationData: animation.export()
})
}, 1000)
setTimeout(function(){
clearInterval(timer);
},1000)
},