【发布时间】:2017-08-16 12:25:42
【问题描述】:
我一直在尝试修复此错误并尝试使字符包含在将是 int 的行中。
func isRightTileAt(location:CGPoint) ->Bool {
//as shape node so we can get fill
var currentRect = self.atPoint(location) as! SKShapeNode
//get the 10th character which will contain the row and make it an int
// let rowOfNode = Int(currentRect.name![10]) //error(tried both of these)
var rowOfNode = Int(currentRect(name[10])) //error
//flip position is used for the row index below the screen to flip it to the top.
var currentRow = self.flipPosition + 1
var currentRowOfClick = self.flipPosition
//we reuse the flip position because it hasn't flipped yet but it normally contains the right row.
//because flip position happens after this check so it won't be sent back around yet
if self.flipPosition == 5 {
currentRowOfClick = 0
}
//if they are at least on the right row
if rowOfNode == currentRowOfClick && currentRect.fillColor.hash == 65536{
return true
}
return false
}
【问题讨论】:
-
什么是
name。你还可以展示atPoint()方法吗?这真的是返回一个 SKShapeNode 吗? -
@RyanPoolos atPoint() 是 SKNode 类的实例方法。
-
@Bran currentRect 在最好的情况下是 SKNode 或其子类。您不能将其用作函数。
标签: ios swift swift3 sprite-kit