令人惊讶的А问题:
let jaba = SKSpriteNode (imageNamed: "jaba0")
let jabaAnimationThrow: SKAction
for i in 0...1 {
texturesJaba.append(SKTexture(imageNamed: "jaba\(i)"))
}
jabaAnimationThrow = SKAction.animate(with: texturesJaba,
timePerFrame: 0.30)
func enemyThrow(enemy: SKSpriteNode) {
let enemyRun = (SKAction.repeatForever((SKAction.sequence([SKAction.wait(forDuration: 3, withRange: 2),jabaAnimationThrow]))))
enemy.run(enemyRun)}
enemyThrow(enemy: jaba)问题: SCAstion.animation播放第一帧"jaba1",然后播放帧0 "jaba0"!为什么?
谢谢!
发布于 2018-03-27 04:27:15
我编译了你的代码,它工作得很好。具体步骤如下:
GameScene.swift文件中的
覆盖func didMove(查看: SKView) { let jaba = SKSpriteNode (imageNamed:"jaba0") jaba.position = CGPoint(x: 100,y: 200) //设置所需位置jaba.setScale(0.2) //您可能需要self.addChild(jaba) }在GameScene.swift文件中使用make enemyThrow(enemy: SKSpriteNode)函数后的
(SKAction.repeatForever((SKAction.sequence(SKAction.wait(forDuration: enemyThrow(敌方: SKSpriteNode) { var texturesJaba = SKTexture让jabaAnimationThrow: SKAction for i in 0...1 { texturesJaba.append(SKTexture(imageNamed:"jaba(i)")) } jabaAnimationThrow = SKAction.animate(with: texturesJaba,timePerFrame: 0.30) let enemyRun =jaba 3,withRange: 2),jabaAnimationThrow) enemy.run(enemyRun) }
覆盖func didMove(查看: SKView) { let jaba = SKSpriteNode (imageNamed:"jaba0") jaba.position = CGPoint(x: 100,y: 200) //设置您想要的位置jaba.setScale(0.2) //您可能需要的任何比例self.addChild(jaba) //调用函数enemyThrow here enemyThrow(敌人: jaba) }
https://stackoverflow.com/questions/49486381
复制相似问题