我想知道是否有人可以回答我的问题。我用Sprite-kit中的纹理地图创建了3种不同的敌人动画,我想知道是否有一种方法,一旦游戏开始,敌人就会随机选择朝着玩家移动。在spritekit中随机化不同的敌人向玩家移动
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))
}
//
你可以发表你曾尝试过的吗 –
我还没有尝试过,我正在考虑在我的spawnEnemy函数中创建一个“possibleEnemy”函数。任何想法实现这一目标? – sicvayne