【发布时间】:2012-05-18 12:30:34
【问题描述】:
我正在开发一个音乐应用程序,所以我真的不能批准任何延迟。
我正在使用心爱的 touchesBegan/Moved/Ended 来处理我的触摸。 一切进展顺利,我设法合成了一个音调(使用 AudioUnit)并在手指下显示了一个发光(使用 GLKit),如果同时击中少于 4-7 个音符/触摸,这一切都很好,然后它就发疯了,让应用卡住了。
我明白这是因为我正在做很多工作(使用 GLKit 界面和我为合成引擎制作的界面),我需要一种方法来修复它。
我的代码是这样构建的:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for(UITouch *touch in touches)
{
CGPoint lePoint = [touch locationInView:self.view];
doing some calculataions for synth engine.......
actually making the sound avilable to play through the interface........
then I start to create the sprite object for the glow
attaching it to the nsarray of the shapes
//rejoycing in the awesomness of the sound
adding the touch to the active touches array
}
}
我在 touchesEnded 中完全相反。
所以为了让它更好地工作,我尝试将 GCD 用于 GLKit 的东西,这样它就会异步发生, 它有效,但有时我会看到屏幕上的光晕,因为当 touchesEnded 试图移除它时它不在数组中。
所以这没有用,我有点无能为力,如果有人可以帮助我,我会很感激。
【问题讨论】:
标签: ios cocoa-touch audiounit touchesbegan glkit