2022.09.25 Programming  spritekit  swiftui  
 2022.09.19 Programming  swiftui  
 2022.09.11 Programming  swiftui  
 2022.09.04 Programming  swiftui  
 2022.08.28 Programming  spritekit  
 2022.08.28 Programming  spritekit  
 2022.08.28 Programming  spritekit  
 2022.07.31 Programming  spritekit  
 2022.07.10 Programming  spritekit  
 2022.07.03 Programming  spritekit  
 2022.06.26 Programming  spritekit  
 2022.06.19 Programming  spritekit  
 2022.06.14 Programming  spritekit  swiftui  
 2022.06.04 Programming  spritekit  
 2022.05.22 Programming  spritekit  
 2022.05.04 Programming  spritekit  
 2022.04.29 Programming  spritekit  
 2022.04.24 Programming  spritekit  

Physics1


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?) {
 }
}