我在sceneKit视图中添加了一个自定义按钮.触摸时,它会播放动画,表示已单击.我面临的问题是用户触摸和动画开始之间的延迟.我的场景有28.1K三角形和84.4K顶点.是那么多,还是我需要以不同的方式实现按钮.场景渲染为60fps.我通过sceneView.addSubview添加了按钮:谢谢你的回答
viewDidLoad(){ // relevant code starButton = UIButton(type: UIButtonType.Custom) starButton.frame = CGRectMake(100,100,50,50) starButton.setImage(UIImage(named: "yellowstar.png"),forState: UIControlState.Normal) sceneView.addSubview(starButton) starButton.addTarget(self,action: "starButtonClicked",forControlEvents: UIControlEvents.TouchUpInside) starButton.adjustsImageWhenHighlighted = false } func starButtonClicked(){ animateScaleDown() } func animateScaleDown(){ UIView.animateWithDuration(0.1,animations: { self.starButton.transform = CGAffineTransformMakeScale(0.8,0.8) },completion: { _ in self.wait() }) } func wait(){ UIView.animateWithDuration(0.2,animations: {},completion: { _ in UIView.animateWithDuration(0.2,animations: { self.starButton.transform = CGAffineTransformMakeScale(1,1) }) }) }