좋아, 이것은 어렵지 않아서 실망 스럽다. 사용자가 손가락을 내릴 때마다 스프라이트 노드가 한 방향으로 영원히 움직이게해야합니다. 여기에 내가 직접 힘을 적용하고 접촉이 종료 할 때 제거되는 반복 skaction을 가진, 그러나 SKaction.moveBy를 사용하여 시도, 터치에서 그런칸트가 스프라이트 노드를 영원히 한 방향으로 이동시키지 않습니까?
character.size = CGSize(width: 58, height: 139)
character.color = UIColor.red
character.position = CGPoint(x: (scene?.size.width)!/2, y: (scene?.size.height)!/2)
character.zPosition = 3
character.physicsBody = SKPhysicsBody(rectangleOf: character.size)
character.physicsBody?.isDynamic = true
character.physicsBody?.affectedByGravity = false
character.physicsBody?.allowsRotation = false
이 시작된 내 스프라이트 노드 생성, 노드는 (10)를 이동 다시 스냅
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touch!")
isTouching = true
let touch = touches.first!
//
let movement = CGVector(
dx: 10,
dy: 1
)
let move = SKAction.moveBy(x: character.position.x+10, y: 0, duration: 1)
//let move = SKAction.applyForce(movement, duration: 0.5)
character.run(SKAction.repeatForever(move), withKey: "moving")
나는 character.position.x를 사용하므로 왜 영원히 오른쪽으로 이동하지 않는지 알 수 없습니다. 노드를 방향으로 계속 움직이게하려면 어떻게해야합니까?
http://stackoverflow.com/q/41220072/1430420과 비슷합니까? –