我有一个以编程方式创建的平面,我想获得该平面所具有的一个顶点的坐标.像这样的东西:print(Plane.vertices[1].position)它可能会打印如下:(x:1,y:1),并print(Plane.vertices[2].position)打印(x - 1,y:1)
let positions = [SCNVector3Make( 0, -0.1, 0),
SCNVector3Make( 0.3, -0.1, 0),
SCNVector3Make( 0, 0.1, 0),
SCNVector3Make( 0.3, 0.1, 0),
]
let indices :[UInt16] = [
0, 1, 2,
1, 3, 2,
]
let vertexSource = SCNGeometrySource(vertices: positions, count: 4)
let indexData = NSData(bytes: indices, length: MemoryLayout<CInt>.size * indices.count)
let newElement = SCNGeometryElement(data: NSData(bytes: indices, length: indices.count * MemoryLayout<Int16>.size) as Data, primitiveType: .triangles , primitiveCount: 2, bytesPerIndex: MemoryLayout<Int16>.size)
let geometry = SCNGeometry(sources: [vertexSource], …Run Code Online (Sandbox Code Playgroud) 我有一个精灵,如果按下精灵,我想打印一些文字.我在其上找到的每个教程似乎都已过时.这怎么可能?
它应该是这样的:
if Sprite is touched {
print("Some Text")
}
Run Code Online (Sandbox Code Playgroud) 所以,如果我有类似的东西:
class game: SKScene {
let sprite = SKSpriteNode(imageNamed: "sprite")
}
Run Code Online (Sandbox Code Playgroud)
如何制作一个点/精灵/形状,它将首先朝向它旋转,然后朝着它移动(而不是它),持续时间为1秒.