나는 충돌로 내 배경이 움직이지 않도록하려합니다. ? 내가 bg.run을 중지 할 수 있습니다 방법함수 내에서 SKAction.repeatForever를 신속하게 중지 하시겠습니까?
let bgTexture = SKTexture(imageNamed: "bg.png")
let moveBGanimation = SKAction.move(by: CGVector(dx: 0, dy: -bgTexture.size().height), duration: 4)
let shiftBGAnimation = SKAction.move(by: CGVector(dx: 0, dy: bgTexture.size().height), duration: 0)
let moveBGForever = SKAction.repeatForever(SKAction.sequence([moveBGanimation, shiftBGAnimation]))
var i: CGFloat = 0
while i < 3 {
bg = SKSpriteNode(texture: bgTexture)
bg.position = CGPoint(x: self.frame.midX, y: bgTexture.size().height * i)
bg.size.width = self.frame.width
bg.zPosition = -2
bg.run(moveBGForever)
self.addChild(bg)
i += 1
}
(moveBGForever 내가 해봤 bg.removeAllActions()도 주요하지만 아무튼에 추가 시도 :
이 만들고 이동 배경을 것입니다 . '는 t는
if contact.bodyA.categoryBitMask == ColliderType.object.rawValue || contact.bodyB.categoryBitMask == ColliderType.object.rawValue {
}
내 솔루션으로 질문을 변경하지 말고주기 코드를 유지해야합니다. 그렇지 않으면 모든 스레드가 이해할 수 없게됩니다. 질문의 마지막 부분에 업데이트를 추가해야합니다. –
예, 물론 되돌 렸습니다. 다시 지금! 카운트가있는 반복 작업에 어떻게 키를 추가 할 수 있습니까? ".repeat (yourBgActions, count : 3)" –
예. 카운트 번호를 넣을 수있는 곳에 'SKAction.repeat' 액션을 새로 만들어야합니다. 당신이 해냈을 때'self.run (actionRepeated, withKey : "yourKey")' –