난이도에 따라 상단바의 속도가 달라집니다.
물체의 형태를 나타내준다.
varball=SKSpriteNode()varenemy=SKSpriteNode()varmain=SKSpriteNode()vartopLabel=SKLabelNode()varbottonLabel=SKLabelNode()
오버라이드 된 didMove 함수 내부에 형태와 포지션을 정의해준다.
overridefunc didMove(to view:SKView){ topLabel =self.childNode(withName:"topLabel")as!SKLabelNode bottonLabel =self.childNode(withName:"bottomLabel")as!SKLabelNode ball =self.childNode(withName:"ball")as!SKSpriteNode enemy =self.childNode(withName:"enemy")as!SKSpriteNode enemy.position.y =(self.frame.height /2)-50 main =self.childNode(withName:"main")as!SKSpriteNode main.position.y =(-self.frame.height /2)+50 // 시뮬레이션을 나타낼 공간을 할당 letborder=SKPhysicsBody(edgeLoopFrom:self.frame) // border.friction =0 border.restitution =1self.physicsBody = border startGame()}func startGame(){ score =[0,-1] topLabel.text ="\(score[1])" bottonLabel.text ="\(score[0])" ball.physicsBody?.applyImpulse(CGVector(dx:10, dy:10))}
움직임을 나타내기 위해 사용
ball.physicsBody?.applyImpulse(CGVector(dx:10, dy:10))
SKAction.moveTo() 사용
// x축 이동 fortouchin touches{letlocation= touch.location(in:self) enemy.run(SKAction.moveTo(x: location.x, duration:0.2))}




