大宮盆栽デイズ - Omiya Bonsai Days -

冗談めかす埼玉のファインマン

楕円起動@コードを学ぼう3

// 楕円起動@コードを学ぼう3
var images = [#imageLiteral(resourceName: "soccerball@2x.png"), #imageLiteral(resourceName: "rugbyball@2x.png"), #imageLiteral(resourceName: "tennisball@2x.png"), #imageLiteral(resourceName: "baseball@2x.png"), #imageLiteral(resourceName: "basketball@2x.png")]

for image in images {
    var graphic = Graphic(image: image)
    scene.place(graphic, at: theOrigin)
    
    // Get random values for orbit parameters.
    let x = randomDouble(from: 50, to: 400)
    let y = randomDouble(from: 50, to: 400)
    let period = randomDouble(from: 1.0, to: 10.0)
    
    // Put graphic into orbit.
    graphic.orbit(x: x, y: y, period: period)
}

youtu.be