为什么我不能在函数Swift中使用self
发布时间:2020-12-14 05:23:08 所属栏目:百科 来源:网络整理
导读:我正在尝试将SKSpriteNodes添加到函数中的视图中,但 Xcode不允许我这样做.它给了我错误“使用未解析的标识符’self’” func indicate() {if test == 0 { var large = ((CGFloat(largest)*54) - 29) - selectedNode.position.x var small = selectedNode.pos
我正在尝试将SKSpriteNodes添加到函数中的视图中,但
Xcode不允许我这样做.它给了我错误“使用未解析的标识符’self’”
func indicate() { if test == 0 { var large = ((CGFloat(largest)*54) - 29) - selectedNode.position.x var small = selectedNode.position.x - ((CGFloat(smallest)*54) - 29) indicatorRight.position = CGPointMake(selectedNode.position.x + large,selectedNode.position.y) indicatorRight.userInteractionEnabled = true indicatorRight.zPosition = 0.5 indicatorLeft.position = CGPointMake(selectedNode.position.x - small,selectedNode.position.y) indicatorLeft.userInteractionEnabled = true indicatorLeft.zPosition = 0.5 println(indicatorLeft.position) // println(smallest) self.addChild(indicatorRight) self.addChild(indicatorLeft) } }
确保方法在类打开和关闭括号中显示
A级 //你需要在这里定义一个方法 } //你可能在这里宣布了它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |