GKNoiseMapsのApple Docsをフォローしていて、スポーンする画像を取得することができました。
ここでこのコードを使用して
class GameScene: SKScene {
class Noise: GKNoise {
var NoiseSource = GKPerlinNoiseSource(frequency: 0.05, octaveCount: 3, persistence: 1, lacunarity: 1, seed: Int32(arc4random_uniform(UInt32(500 - 1))))
override init(_ noiseSource: GKNoiseSource, gradientColors: [NSNumber : UIColor]) {
super.init(NoiseSource, gradientColors: [ (+1.0 as NSNumber): UIColor.red, (-1.0 as NSNumber) : UIColor.black])
}
}
let noise = Noise()
let Vector1 = vector_double2(1.0, 1.0)
override func didMove(to view: SKView) {
let NoiseMap = GKNoiseMap(noise, size: vector_double2(300.0, 300.0),
origin: vector_double2(0.0, 0.0),
sampleCount: vector_int2(100),
seamless: true)
let texture = SKTexture(noiseMap: NoiseMap)
let Node = SKSpriteNode(texture: texture)
Node.size = CGSize(width: 1000,height: 1000)
Node.position = CGPoint(x: 0,y: 0)
self.addChild(Node)
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
}
ここで、この更新されたコードを使用して SKTileMap を作成するにはどうすればよいですか
class GameScene: SKScene {
class Noise: GKNoise {
var NoiseSource = GKPerlinNoiseSource(frequency: 0.05, octaveCount: 3, persistence: 1, lacunarity: 1, seed: Int32(arc4random_uniform(UInt32(500 - 1))))
override init(_ noiseSource: GKNoiseSource, gradientColors: [NSNumber : UIColor]) {
super.init(NoiseSource, gradientColors: [(+1.0 as NSNumber): UIColor.red, (-1.0 as NSNumber) : UIColor.black])
}
}
let noise = Noise()
let Vector1 = vector_double2(1.0, 1.0)
override func didMove(to view: SKView) {
let NoiseMap = GKNoiseMap(noise, size: vector_double2(300.0, 300.0),
origin: vector_double2(0.0, 0.0),
sampleCount: vector_int2(100),
seamless: true)
let tileGroup = [SKTileGroup]()
let tileSet = SKTileSet(tileGroups: tileGroup)
let map = SKTileMapNode(tileSet: tileSet, columns: 10, rows: 10, tileSize: CGSize(width: 20,height: 20), tileGroupLayout: tileGroup)
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
}
Apple Docsに記載されているように、GKNoiseMapの値でSKTileMapを生成しますか?
SKTileMapsとそれらがどのように機能するかについて本当に知らないので、助けていただければ幸いです