我目前有一个节点,每次触摸时我都希望它绕其中心旋转 90 度。我已经设法使用下面的代码旋转它,但不是围绕它的中心。如果有人有办法解决这个问题,我将非常感激。
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as! UITouch
let touchLocation = touch.locationInNode(self)
if sprite.frame.contains(touchLocation) {
let rotate = SKAction.rotateByAngle(1.57, duration: 0.1)
sprite.runAction(rotate)
}
}
最佳答案
我怀疑你需要为你的 Sprite 设置正确的 anchor :
sprite.anchorPoint = CGPoint(0.5, 0.5)
关于ios - 绕中心旋转节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31691490/