gpt4 book ai didi

swift - 我想在 ARKit 中制作图像列表,但无法返回它

转载 作者:行者123 更新时间:2023-11-30 12:05:32 25 4
gpt4 key购买 nike

我在其他人的帮助下制作了该列表,但我需要返回该节点,它显示“错误使用未解析的标识符节点。”

这是代码:

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.
}

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

最佳答案

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.
}

关于swift - 我想在 ARKit 中制作图像列表,但无法返回它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46718628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com