我想知道是否有人可以回答我的问题。我在 Sprite-kit 中使用纹理图集创建了 3 个不同的敌人动画,我想知道是否有一种方法可以在游戏开始时随机选择一个敌人向玩家移动。
TextureAtlas = SKTextureAtlas(named: "zombies.atlas")
for i in 1...TextureAtlas.textureNames.count {
let Z = "z\(i).png"
zombieArray.append(SKTexture(imageNamed: Z))
}
TextureAtlas = SKTextureAtlas(named: "baldzomb.atlas")
for i in 1...TextureAtlas.textureNames.count {
let bald = "baldzomb_\(i).png"
baldArray.append(SKTexture(imageNamed: bald))
}
TextureAtlas = SKTextureAtlas(named: "crawler.atlas")
for i in 1...TextureAtlas.textureNames.count {
let Name = "crawler_\(i).png"
crawlerArray.append(SKTexture(imageNamed: Name))
}