我是斯威夫特的noobie.我无法弄清楚为什么这段代码:
class GameScene: SKScene, SKPhysicsContactDelegate {
var statements = Statements()
override func didMoveToView(view: SKView) {
runAction(SKAction.repeatActionForever(
SKAction.sequence([
SKAction.runBlock(addLabel(statements)),
SKAction.waitForDuration(2.0)
])
))
}
func addLabel(statements: Statements) {...}
}
Run Code Online (Sandbox Code Playgroud)
结果:在调用中缺少参数"完成"的参数
Cod*_*aFi 10
类型检查器中的另一个奇怪的错误.因为self.addLabel(self.statements)不是Void -> Void它的类型Void,编译器假设你在其他地方调用另一个方法(其他地方的地方,我没有线索.没有任何方法runBlock(_:)可以找到任何我能找到的方法).当这样的事情发生时尝试一个明确的闭包
class GameScene: SKScene {
var statements = Statements()
override func didMoveToView(view: SKView) {
runAction(SKAction.repeatActionForever(SKAction.sequence([
SKAction.runBlock({ self.addLabel(self.statements) }),
SKAction.waitForDuration(2.0)
])))
}
func addLabel(statements: Statements) -> Void { }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3947 次 |
| 最近记录: |