Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Space out the graphics.
- let placeDistance = touch.position.distance(from: lastPlacePosition)
- if placeDistance < /*#-editable-code*/80/*#-end-editable-code*/ { return }
- lastPlacePosition = touch.position
- // animals数列から動物をランダムにピックアップ
- let chosenImage = animals.randomItem
- // ピックアップした動物をgraphics数列に3つ入れる
- for i in 0 ..< 4 {
- let graphic = Graphic(image: chosenImage)
- graphics.append(graphic)
- }
- // 画面をタッチした絶対座標を求める
- let x = abs(touch.position.x)
- let y = abs(touch.position.y)
- // 右上・右下・左上・左下の座標を決める
- let position1 = Point(x: x, y: y)
- let position2 = Point(x: -x, y: y)
- let position3 = Point(x: x, y: -y)
- let position4 = Point(x: -x, y: -y)
- //このforループの意味がわからない
- for i in 0 ..< 4 {
- if i == 0 {
- scene.place(graphics[i], at: position1)
- } else if i == 1 {
- scene.place(graphics[i], at: position2)
- } else if i == 2 {
- scene.place(graphics[i], at: position3)
- } else if i == 3 {
- scene.place(graphics[i], at: position4)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement