// 絵文字ふぶき@コードを学ぼう3 let emoji = "✨🌝🔦💫👀☄️🌎" // Split emoji into an array of single-character strings. // 文字列を、一文字ずつ分けて配列に入れる let characters = emoji.componentsByCharacter() // characters の次のアイテムを取るためのインデックス var index = 0 func addText(touch: Touch) { if touch.previousPlaceDistance < 80 { return } // var chosenEmoji = "🐠" // Set chosenEmoji to item index of characters array. var chosenEmoji = characters[index] // Create graphic from the chosen emoji. let graphic = Graphic(text: chosenEmoji) // Increment index to point to next item. index += 1 // Reset index if it’s reached the end of the array. if index == characters.count { index = 0 } // Set `scale` and `rotation`. graphic.scale = 1.5 graphic.rotation = randomDouble(from: 0.0, to: 180) scene.place(graphic, at: touch.position) }