我有一個SKNode(),它有SKCropNode()子元素。我能夠運行所有類型的動作來旋轉和縮放我的SKNode(),但是當我想要使用任何類型的淡入淡出操作時,結果總是爲alpha 1或alpha 0。沒有任何淡入淡出的方式。使用SKCropNode()的SKNode()的淡出操作()兒童
通過用SKShapeNode()替換SKCropNode()淡出操作正常工作。
誰能告訴我爲什麼?是不是可以淡化蒙面節點?
import SpriteKit
class GameScene: SKScene {
let player = SKNode()
let playerSize = CGFloat(50)
let playerCrop = SKCropNode()
let playerMask = SKSpriteNode(color: SKColor.blackColor(), size: CGSizeMake(CGFloat(100), CGFloat(100)))
let playerCircle = SKShapeNode(circleOfRadius: CGFloat(100))
let playerCenterMask = SKShapeNode(circleOfRadius: CGFloat(100))
let playerCenterCrop = SKCropNode()
override func didMoveToView(view: SKView) {
backgroundColor = SKColor.blackColor()
player.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame))
player.alpha = 0
addChild(player)
playerCenterMask.lineWidth = 20
playerCenterCrop.maskNode = playerCenterMask
playerMask.position.x = -playerSize
playerMask.position.y = playerSize
playerCircle.lineWidth = 0
playerCircle.fillColor = SKColor.redColor()
playerCrop.addChild(playerCircle)
playerCrop.maskNode = playerMask
playerCenterCrop.addChild(playerCrop)
player.addChild(playerCenterCrop)
// Animations
let playerScale = SKAction.scaleTo(2.0, duration: 5)
let playerFadeIn = SKAction.fadeInWithDuration(5)
let playerAnimation = SKAction.group([playerScale,playerFadeIn])
player.runAction(playerAnimation, completion: {})
}
}
你可以發佈您的代碼,所以我可以嘗試一下 – hamobi
謝謝,我加入了一些示例代碼:) – Cherrypig
嘗試設置面膜清除顏色,而不是黑色,阿爾法值爲1,所以你說所有阿爾法 – Knight0fDragon