小编Asp*_*hys的帖子

获取节点scenekit中顶点的位置

我有一个以编程方式创建的平面,我想获得该平面所具有的一个顶点的坐标.像这样的东西: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)

scenekit swift

4
推荐指数
1
解决办法
2460
查看次数

如何检测spritekit中的触摸?

我有一个精灵,如果按下精灵,我想打印一些文字.我在其上找到的每个教程似乎都已过时.这怎么可能?

它应该是这样的:

if Sprite is touched {
    print("Some Text")
}
Run Code Online (Sandbox Code Playgroud)

xcode touch sprite-kit swift

2
推荐指数
1
解决办法
2971
查看次数

将精灵旋转到一个点并以持续时间向它移动

所以,如果我有类似的东西:

class game: SKScene {
    let sprite = SKSpriteNode(imageNamed: "sprite")
}
Run Code Online (Sandbox Code Playgroud)

如何制作一个点/精灵/形状,它将首先朝向它旋转,然后朝着它移动(而不是它),持续时间为1秒.

touch sprite-kit swift

0
推荐指数
1
解决办法
973
查看次数

标签 统计

swift ×3

sprite-kit ×2

touch ×2

scenekit ×1

xcode ×1