我无法让runAction方法适用于此代码块。我不确定我做错了什么或者块外有什么问题,但是如果有人看到任何内部错误,让我们从那里开始(*编辑包括整个功能)。所有变量都有效,我得到零编译错误,程序似乎跳过了行currentTestIndicator.runAction(SKAction.sequence(runCheck))
。除recurse
内的所有打印语句外,所有打印语句都有效,同时current++
也未被调用。我尝试在没有recurse
的情况下运行代码,但仍然无效。想法?
func runLevelCheck(node: SKSpriteNode, _ state: SKSpriteNode, _ bluePatterns:Array<Array<String>>, _ blueSize: CGFloat, _ blueLocations: Array<CGPoint>, _ greenPatterns:Array<Array<String>>, _ greenSize: CGFloat, _ greenLocations:Array<CGPoint>, _ redPatterns:Array<Array<String>>, _ redSize: CGFloat, _ redLocations:Array<CGPoint>, _ orangePatterns:Array<Array<String>>, _ orangeSize: CGFloat, _ orangeLocations:Array<CGPoint>)->Bool {
var passLevel = true
var current = 0
let currentTestIndicator = SKSpriteNode()
currentTestIndicator.name = "indicator"
currentTestIndicator.size = CGSizeMake(0, 128)
blueLocations[current].y)
currentTestIndicator.anchorPoint = CGPoint(x: 0.0, y: 0.5)
currentTestIndicator.zPosition = 0
node.addChild(currentTestIndicator)
let patterns = [bluePatterns, greenPatterns, redPatterns, orangePatterns]
let sizes = [blueSize, greenSize, redSize, orangeSize]
let locations = [blueLocations, greenLocations, redLocations, orangeLocations]
let colors = [color("Light Blue 01"), color("Light Green 01"), color("Light Red 01"), color("Light Orange 01")]
for sets in patterns {
for rows in sets {
if rows != [] {
print("Current set: \(current)")
print(rows)
currentTestIndicator.color = colors[current]
currentTestIndicator.position = CGPoint(x: 0.0, y: locations[current][0].y)
print(currentTestIndicator.position)
print("Sizes current = \(sizes[current])")
let growRight = SKAction.resizeToWidth(sizes[current], duration: 0.2)
let recurse = SKAction.runBlock() {
recursion(state, rows, 0, 0, &passLevel)
current++
print("Changed current value to \(current)")
}
let pause = SKAction.waitForDuration(5.0)
let shrinkLeft = SKAction.resizeToWidth(0, duration: 0.2)
let runCheck = [growRight, recurse, pause, shrinkLeft]
currentTestIndicator.runAction(SKAction.sequence(runCheck))
}
}
current = 0
}
currentTestIndicator.removeFromParent()
print("Ran level check")
switch passLevel {
case true:
print("Level passed")
case false:
print("Lavel failed")
}
return passLevel
}