GameScene
class GameScene: SKScene, SKPhysicsContactDelegate {
override func didMove(to view: SKView) {
backgroundColor = .blue
self.physicsWorld.contactDelegate = self
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
physicsWorld.gravity = CGVector(dx: 0.0, dy: 0.0)
let ball = SKShapeNode(circleOfRadius: 40) //circleOfRadiusで円の半径
ball.position = CGPoint(x:self.frame.midX, y:self.frame.midY+200)
ball.fillColor = UIColor.red
ball.lineWidth = 0.0
ball.strokeColor = UIColor.red
ball.physicsBody = SKPhysicsBody(circleOfRadius: ball.frame.width/2)
self.addChild(ball)
//ボールの飛んでいく方向
ball.physicsBody?.applyImpulse(CGVector(dx: 40, dy: 40))
ball.physicsBody?.restitution = 1
ball.physicsBody?.friction = 0
ball.physicsBody?.linearDamping = 0
let label = SKLabelNode(fontNamed: "HelveticaNeue-Light")
label.text = "Hello World!"
label.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
label.fontSize = 40
label.fontColor = SKColor.white
self.addChild(label)
}
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
}
}