自分だけのプロジェクト@コードを学ぼう3
遊んでいるのか、遊ばされているのかわからなくなってきました。コードの一部をちょこちょこ入力するだけでは学習にならない気がします。とりあえず、最低限のコードを入力して、次のステージへと進みます。
// 自分だけのプロジェクト@コードを学ぼう3 // Clear the scene. scene.clear() // Use your own background image. scene.backgroundImage = #imageLiteral(resourceName: "SpaceThePurpleFrontier@2x.png") // Add your own code to set up the scene. // With the Image tool selected, this function is called each time your finger moves. func addImage(touch: Touch) { if touch.previousPlaceDistance < 80 { return } // Replace with your own code. let graphic = Graphic(image: #imageLiteral(resourceName: "ogre@2x.png")) graphic.scale = randomDouble(from: 2, to: 4) graphic.rotation = randomDouble(from: 0, to: 180) scene.place(graphic, at: touch.position) graphic.swirlAway(after: randomDouble(from: 1, to: 4)) } let emoji = "😺🚗🎃🚕🤢🚙" // Split emoji into an array of single-character strings. let characters = emoji.componentsByCharacter() // Index to next character. var index = 0 // With the Text tool selected, this function is called each time your finger moves. func addText(touch: Touch) { if touch.previousPlaceDistance < 80 { return } // Replace with your own code. let graphic = Graphic(text: characters[index]) graphic.scale = 2.5 scene.place(graphic, at: touch.position) graphic.fadeOut(after: randomDouble(from: 1, to: 4)) index += 1 if index == characters.count { index = 0 } }