1
我試圖建立一個倒數計時器,併爲每個計數我想播放聲音。動畫工作正常,但我想知道如果我可以在按順序運行動畫時播放聲音。如何在運行動畫序列時添加副作用(播放聲音)?
CODE:
Animated.sequence([
Animated.timing(this.state.moveY3, {
toValue: 50,
duration: 1000,
useNativeDrive: true,
easing: Easing.spring
}), // play sound
Animated.timing(this.state.moveY3, {
toValue: 100,
duration: 100,
useNativeDrive: true,
}),
Animated.timing(this.state.moveY2, {
toValue: 50,
duration: 1000,
useNativeDrive: true,
easing: Easing.spring
}), //play sound
Animated.timing(this.state.moveY2, {
toValue: 100,
duration: 500,
useNativeDrive: true,
}),
Animated.timing(this.state.moveY1, {
toValue: 50,
duration: 1000,
useNativeDrive: true,
easing: Easing.spring
}), // play sound
Animated.timing(this.state.moveY1, {
toValue: 100,
duration: 500,
useNativeDrive: true,
}),
]).start()
注:我知道如何使用反應本地聲音包打聲音,IM,我只是困惑,如何穩妥的打法,在每個計數。
真棒謝謝 –
優秀的答案 –