2016-03-10 85 views
0

我試着去實現這個代碼,一個UIView但對於一個SKSprite節點:斯威夫特:轉換SKSpriteNode

stopIcon.transform = CGAffineTransformMakeScale(0.01, 0.01) 

UIView.animateWithDuration(0.5, animations: {() -> Void in 
     self.stopIcon.transform = CGAffineTransformMakeScale(1.0, 1.0) 
     }) 

我SKSprite節點設置這樣的:

stopIcon = SKSpriteNode(imageNamed: "StopIcon") 
    stopIcon?.size = CGSize(width: ((stopImage?.size.width)! * 0.75), height: ((stopImage?.size.height)! * 0.75)) 
    stopIcon?.position = CGPoint(x: self.size.width * 0.22, y: self.size.height * 0.91) 
    self.addChild(stopIcon!) 

謝謝大家。

回答

1

我猜你想從0.1 - > 1.0(原始尺度的十分之一到滿量程)的0.5秒內縮放SKSpriteNode。

使用SpriteKit的SKAction類這可以像這樣實現:

//set the inital scale of node to 0.1 
stopIcon.setScale(0.1) 
//create action to scale skspritenode to scale of 1.0 over 0.5 seconds. 
let scaleAction = SKAction.scaleTo(1.0, duration: 0.5) 
//call on the action. 
stopIcon.runAction(scaleAction) 
+0

你是了不起的! – OriginalAlchemist