update
방법이 SKScene
인 경우 화면 밖으로 나가면 background
을 다시 설정할 수 있습니다.
랩 어라운드 효과를 만들려면 다음과 같은 두 가지 배경 스프라이트 노드를 만듭니다. 두 배경은 서로 위아래로 유지됩니다.
background1 = SKSpriteNode(texture: bgTexture)
background1.position = CGPoint(x:CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))
background1.size.height = self.frame.height
background2 = SKSpriteNode(texture: bgTexture)
background2.position = CGPoint(x:CGRectGetMidX(self.frame) , y: CGRectGetMidY(self.frame)+ self.frame.size.height)
background2.size.height = self.frame.height
self.addChild(background1)
self.addChild(background2)
이어서 touchesBegan
함수
if background1.position.y + background1.size.height/2 < 50
{
let diff = background1.position.y + background1.size.height/2 - 50
background1.position.y = self.frame.height + background1.size.height/2 + diff
}
else
{
background1.position.y -= 50
}
if background2.position.y + background2.size.height/2 < 50
{
let diff = background2.position.y + background2.size.height/2 - 50
background2.position.y = self.frame.height + background2.size.height/2 + diff
}
else
{
background2.position.y -= 50
}
위의 코드를 더 모듈화 할 수있다. 하지만 나는 너에게 맡긴다.