我试图为UIView实现此代码,但是对于SKSprite节点:
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!)
谢谢大家。
答案 0 :(得分:2)
我猜你想在0.5秒内缩放SKSpriteNode,从0.1 - > 1.0(满刻度的十分之一)。
使用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)