AM(SKNode *在节点的节点)新迅速和学习 我用 “为(SKNode *在节点的节点)” 用于在Objective-C与它的名字中选择特定的节点,但在迅疾我需要一些帮助来做到这一点。在此先感谢在迅速
在SWIFT
Q
在迅速
-3
A
回答
1
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject() as UITouch
let touchLocation = touch.locationInNode(self)
let nodes = self.nodesAtPoint(touchLocation) as [SKNode]
for node in nodes {
if let nodeName = node.name {
if nodeName == "myNodeName" {
println("node tapped")
}
}
}
}
要检查如果一个节点被窃听,与迭代循环。循环浏览SKNodes,并检查节点名称是否匹配。不同的是,代替(SkNode *节点),我们有:
let nodes = self.nodesAtPoint(touchLocation) as [SKNode]
0
for node in nodes {
}
0
这里是迅速使用 “for” 循环一个简单的例子:
let arrStrings = ["one","two","three","four"]
for str in arrStrings
{
if str=="two"
{
println("\(str)")
}
}
相关问题
- 1. UIViews在迅速
- 2. 在迅速
- 3. 在迅速
- 4. 在迅速3
- 5. XML在迅速
- 6. 在迅速
- 7. 在迅速
- 8. 在迅速
- 9. 在迅速
- 10. 在迅速
- 11. 在迅速
- 12. 在迅速4
- 13. 在迅速
- 14. 在迅速
- 15. 在迅速
- 16. 在迅速
- 17. 在迅速
- 18. 在迅速
- 19. 在迅速
- 20. 在迅速
- 21. NSRegularExpressions在迅速
- 22. mutableCopy在迅速
- 23. barTintColor在迅速
- 24. 在迅速
- 25. modalviewcontroller在迅速
- 26. 在迅速
- 27. 在迅速
- 28. 迅速
- 29. 关于在迅速
- 30. 无法在迅速
只是阅读文档:For循环(https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language /ControlFlow.html#//apple_ref/doc/uid/TP40014097-CH9-ID121) – Antonio 2015-03-02 10:12:00