我想在ARKit中制作一个图像列表但我无法返回它

时间:2017-10-12 20:47:52

标签: swift arkit

我已经在其他人的帮助下制作了这个列表,但是我需要返回节点,它说" ERROR使用未解析的标识符节点。"

这是代码:

func view(_ view: ARSKView, nodeFor anchor: ARAnchor) -> SKNode? {
    let arrayOfImages = ["Photo1", "Photo2", "Photo3", "Photo4", "Photo5", "Photo6", "Photo7", "Photo8", "Photo9", "Photo10", "Photo11", "Photo12", "Photo13", "Photo14", "Photo15", "Photo16", "Photo17", "Photo18", "Photo19", "Photo20", "Photo21", "Photo22", "Photo23", "Photo24", "Photo25", "Photo26", "Photo27", "Photo28", "Photo29", "Photo30"]
    let randomIndex = Int(arc4random_uniform(UInt32(arrayOfImages.count)))
    let Image = UIImage(named: arrayOfImages[randomIndex])
    let Texture = SKTexture(image: Image!)
    let Sprite = SKSpriteNode(texture:Texture)
return node               //ERROR use of unresolved identifier node.
}     

如果有人能帮助我,我将非常感激。

1 个答案:

答案 0 :(得分:0)

func view(_ view: ARSKView, nodeFor anchor: ARAnchor) -> SKNode? {
    let arrayOfImages = ["Photo1", "Photo2", "Photo3", "Photo4", "Photo5", "Photo6", "Photo7", "Photo8", "Photo9", "Photo10", "Photo11", "Photo12", "Photo13", "Photo14", "Photo15", "Photo16", "Photo17", "Photo18", "Photo19", "Photo20", "Photo21", "Photo22", "Photo23", "Photo24", "Photo25", "Photo26", "Photo27", "Photo28", "Photo29", "Photo30"]
    let randomIndex = Int(arc4random_uniform(UInt32(arrayOfImages.count)))
    let Image = UIImage(named: arrayOfImages[randomIndex])
    let Texture = SKTexture(image: Image!)
    let Sprite = SKSpriteNode(texture:Texture)
    return Sprite // because it is SKSpriteNode.
}