答案 0 :(得分:1)
使用SKSpriteNode进行翻转的解决方案:
func flipTile(node : RectSprite){
let flip = SKAction.scaleXTo(-1, duration: 0.4)
node.setScale(1.0)
var changeColor = SKAction.runBlock( { node.texture = SKTexture(imageNamed: "blue")})
var action = SKAction.sequence([flip, changeColor] )
node.runAction(action)
}
答案 1 :(得分:0)
上面的代码帮助我在Swift 3中创建了这个函数。注意次要的语法差异,但仍然非常相似。
可能会再次将操作设置为变量并在[]中运行它们,但这对我来说足够简洁。
func flipCard (node: SKNode, label: SKLabelNode)
{
label.isHidden = true
node.run(SKAction.sequence(
[SKAction.scaleX(to: 0, duration: 0.2),
SKAction.scale(to: 1, duration: 0.0),
SKAction.setTexture(SKTexture(imageNamed: "Redcard-blank")),
SKAction.fadeOut(withDuration: 2),
SKAction.fadeIn(withDuration: 2),
SKAction.fadeOut(withDuration: 2),
]
))
label.isHidden = false
}