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