[英]Xcode swift 3 sprite kit animate a image that go up and down
hello I'm coding a app on xcode and i really like to know how to move a SKSpriteNode up and down smooth kind of animated (just like the in Pop The Lock when you complete the level) 你好,我在xcode上编写应用程序,我真的很想知道如何在平滑的动画上上下移动SKSpriteNode(就像完成关卡时的Pop The Lock一样)
SKSpriteNode code SKSpriteNode代码
Lock = SKSpriteNode(imageNamed: "Lock")
Lock.size = CGSize(width: 182, height: 170)
Lock.position = CGPoint(x: CGRectGetMidX(self.frame), y: (self.frame.height / 2 + 180))
Lock.zPosition = -1
self.addChild(Lock)
You can use SKAction for example. 例如,您可以使用SKAction。
//Move Up
let MoveUp = SKAction.MoveToY(self.frame.height / 2 + 280) // +100 up
Lock.runAction(MoveUp)
//Move Down
let MoveDown = SKAction.MoveToY(self.frame.height / 2 + 80) // -100 down
Lock.runAction(MoveDown)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.