因此,我能找到的有关执行此操作的文档非常少。我想念 c++ 的一个重要功能是能够做这样的事情(对于任何语法错误我很抱歉我在 c++ 中有点生疏
Int* Chosenint;
Int option1 = 1
Int option2 = 2
Int option3 = 3
if (the sun is up)
Chosenint = &option1
else
Chosenint = &option2
但是 swift 不识别“*”或“&”运算符。我想要做的就是拥有一个全局变量,该变量存储指向 SKSpriteNode 的指针,并且可以更改为不同的指针。 swift 似乎只有大型的 UnsafeMutablePointer 东西。那么,您将如何使用 skspritenodes 快速编写该 C++ 代码?
最佳答案
All I am trying to do is have a global variable that stores a pointer to a SKSpriteNode, and can change to a different one. All swift seems to have is the large UnsafeMutablePointer thing. So how would you do that c++ code in swift but with skspritenodes?
SKSpriteNode
是一个类,即引用类型,所以你什么都不用做。你得到没有星号和符号的行为。
关于c++ - 如何像我以前在 C++ 中做的那样在 swift 中做指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32303041/