【发布时间】:2016-03-26 11:54:53
【问题描述】:
请人帮忙!
我想让我的 SKEmiterNode 的比例(意思是大小)随着我使用 AVAudioPlayer 内置到应用程序中的音乐变得越来越小。现在,这几乎是我为 SKEmiterNode 所拥有的一切,而且看起来很棒:
beatParticle?.position = CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.5)
var beatParticleEffectNode = SKEffectNode()
beatParticleEffectNode.addChild(beatParticle!)
self.addChild(beatParticleEffectNode)
所有外观都在 .sks 文件中完成。
这是我在连续循环中调用“updateBeatParticle”函数的地方,这样我就可以将我的代码放置在其中,以使粒子的比例(意思是大小)随着音乐变得越来越小。
var dpLink : CADisplayLink?
dpLink = CADisplayLink(target: self, selector: "updateBeatParticle")
dpLink?.addToRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes)
func updateBeatParticle(){
//Put code here
}
知道我该怎么做吗?我看了一些教程,例如:https://www.raywenderlich.com/36475/how-to-make-a-music-visualizer-in-ios
但是,我无法完全理解它,因为他们在 Obj-C 中使用了一个emitterLayer 和它,而且我还对你们这些优秀的人可能有的任何其他想法感兴趣!
【问题讨论】:
标签: ios swift animation avaudioplayer skemitternode