В настоящее время я пытаюсь изменить размер SKShapeNode, перетаскивая верхний правый угол. Одна из проблем, с которой я столкнулся, заключается в том, что в настоящее время у меня есть квадрат, который можно перетаскивать пальцем пользователя, и именно здесь я запутываюсь. Как отличить, когда пользователь меняет положение фигуры, и когда пользователь хочет изменить размер фигуры?
class GameScene: SKScene {
var square: SKShapeNode!
override func didMove(to view: SKView) {
// Create a square
let squareSize = CGSize(width: 100, height: 100)
let squareRect = CGRect(origin: CGPoint(x: -squareSize.width / 2, y: -squareSize.height / 2), size: squareSize)
square = SKShapeNode(rect: squareRect, cornerRadius: 10)
square.fillColor = .blue
square.position = CGPoint(x: frame.midX, y: frame.midY)
addChild(square)
}
override func touchesMoved(_ touches: Set, with event: UIEvent?) {
// Get the touch location
guard let touch = touches.first else { return }
let touchLocation = touch.location(in: self)
// Move the square to the touch location
square.position = touchLocation
}
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... r-dragging