2017-11-08 22 views
1

내 GameScene에서 영웅의 SKSpriteNode를 얻었습니다. 나는 두 개의 버튼 (상하)을 구현한다. 내 영웅의 SKSpriteNode가 버튼 터치로 위아래로 움직이고 있어야합니다. 그러나 나는 단지 touchesMoved와 touchesEnded 메소드 만 볼 수 있습니다. 나는 touchesBegan (내가 그것을 두드리는 동안 버튼 꼭지를 느낀다)에 관해 무언가를 필요로한다.버튼 터치로 SKSpriteNode 이동

답변

0

당신은 터치가 touchesMoved

override func touchesBegan(...) 
{ 
    ... 
    let moveAction = SKAction.repeatForever(SKAction.move(by:CGPoint(x:x,y:y))) 
    node.run(moveAction,forKey:"moving") 
    ... 
} 
override func touchesMoved(...) 
{ 
    ... 
    //add a check to see if if touch.position is not inside the button 
    if (...) 
    { 
     node.removeAction(withKey:"moving") 
    } 
    ... 
} 
override func touchesEnded(...) 
{ 
    ... 
    node.removeAction(withKey:"moving") 
    ... 
} 
override func touchesCancelled(...) 
{ 
    ... 
    node.removeAction(withKey:"moving") 
    ... 
} 
+0

TY를 확인하여 노드 을 이동할 때 touchesBegan에서 시작 touchesEnded에 종료 touchesCancelled 또는 단계를 반복의 어떤 종류를 만들! 너 나 좀 도와 줘! –