Unity-C#

 2024.07.07 unityC#  
 2024.05.15 unityC#  
 2024.05.15 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.08.16 spritekit  

SKAction1


import SpriteKit
import GameplayKit


class GameScene: SKScene {
 override func didMove(to view: SKView) {
  backgroundColor = UIColor.white
  self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
   let myLabel = SKLabelNode(fontNamed: "Arial")
   myLabel.text = "Start"
   myLabel.fontSize = self.frame.width / 8
   myLabel.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
   myLabel.fontColor = SKColor.blue
   self.addChild(myLabel)

   let fadeInAction  = SKAction.fadeAlpha(to: 1.0, duration: 3.0)
   let fadeOutAction = SKAction.fadeAlpha(to: 0.0, duration: 3.0)
   let changeLabelTextAction = SKAction.run({
   myLabel.text = "New Text"
   })
   let actionSequence = SKAction.sequence([fadeOutAction, changeLabelTextAction, fadeInAction])
   myLabel.run(actionSequence)

    //    run(SKAction.repeat(SKAction.sequence([SKAction.run(createBall), SKAction.wait(forDuration: 0.6)]), count: 20))
  let timerWait = SKAction.wait(forDuration: 0.6)
 let shotCheck = SKAction.run {self.createBall()}
  let shotSequence = SKAction.sequence([shotCheck, timerWait])
 let loopShotCheck = SKAction.repeat(shotSequence, count: 20)
  self.run(loopShotCheck)
}
 func createBall() {
let ball = SKShapeNode(circleOfRadius: 50)//circleOfRadiusで円の半径
ball.position = CGPoint(x:self.frame.midX, y:self.frame.midY+250)
ball.fillColor = UIColor.red
ball.lineWidth = 4.0
ball.strokeColor = UIColor.lightGray
    //    let ball = SKSpriteNode(imageNamed: "ball")
    //    ball.position = CGPoint(x: CGFloat(Int.random(in: 0...400) + 200),
    //                            y: size.height - ball.frame.height)
  ball.position = CGPoint(x: CGFloat(Int(arc4random()) % Int(size.width)),
                             y: size.height - ball.frame.height)
  ball.physicsBody = SKPhysicsBody(circleOfRadius: ball.frame.width/2)
    addChild(ball)
 }
}