是否可以在项目的多个位置或对象中使用touchesBegan方法?
例如,如果我有一个带有两个按钮的主类:
class GameScene: SKScene, SKPhysicsContactDelegate {
let moveButton = MoveButton()
let fireButton = FireButton()
//add buttons to scene etc...
}
class MoveButton: SKSpriteNode {
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
NSLog("moved!")
}
}
class FireButton: SKSpriteNode {
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
NSLog("fired!")
}
}
目前我有类似的东西,但是touchesBegan没有被击中,这是不正确的吗?
最佳答案
是的,在几个地方实现touchesBegan
应该很好。关于为什么不打电话给他们,也许可以帮上忙? Custom SKSpriteNode not detected during touch
关于ios - 在多个类别中开始添加touches,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27218627/