0
我已经得到了class Menu: SKScene
,那么func touchesBegan
它里面,给了我的错误:与:“withEvent :)的touchesBegan(”从超类方法法的冲突 - 覆盖给出错误
方法Objective-C的选择 '的touchesBegan:withEvent:方法' 与方法冲突 '的touchesBegan(:withEvent :)' 从超类的UIResponder'具有相同的目标C选择
无论如何,如果在我的前添加超控功能说:
方法不覆盖任何超类中的方法。
任何想法?整个代码:
import SpriteKit
class Menu: SKScene {
var title : SKLabelNode?
var start : SKLabelNode?
override func didMoveToView(view: SKView) {
backgroundColor = SKColor.whiteColor()
self.title = SKLabelNode(fontNamed: "Chalkduster")
self.start = SKLabelNode(fontNamed: "Chalkduster")
self.title!.name = "title"
self.start!.name = "new"
self.addChild(self.title!)
self.addChild(self.start!)
}
func touchesBegan(touches: NSSet, withEvent even: UIEvent) {
self.menuHelper(touches)
}
func menuHelper(touches: NSSet) {
for touch in touches {
let nodeAtTouch = self.nodeAtPoint(touch.locationInNode(self))
if nodeAtTouch.name == "title" {
print("Title pressed")
}
else if nodeAtTouch.name == "new" {
print("Start pressed")
}
}
}
非常感谢您!仍在学习基础知识。 – ffritz