let blu = Graphic(image: #imageLiteral(resourceName: "Blu1@2x.png"))
let theOrigin = Point(x: 0, y: 0)
scene.place(blu, at: theOrigin)
func musicalGraphic(graphic: Graphic) {
if graphic == blu {
playInstrument(.cosmicDrums, note: 12, volume: 50)
}
let x = randomInt(from: 0, to: 15)
if graphic.text == "🍐" {
playInstrument(.bassGuitar, note: x)
} else if graphic.text == "🍊" {
playInstrument(.electricGuitar, note: x)
} else if graphic.text == "🍋" {
playInstrument(.piano, note: x)
}
}
func addFruit(touch: Touch) {
if touch.previousPlaceDistance < 60 { return }
let fruit = "🍐🍊🍋".componentsByCharacter()
let graphic = Graphic(text: fruit.randomItem)
scene.place(graphic, at: touch.position)
graphic.scale = 2.0
}
let fruitTool = Tool(name: "Fruit", emojiIcon: "🍊")
fruitTool.onFingerMoved = addFruit(touch:)
scene.tools.append(fruitTool)
let musicTool = Tool(name: "Music", emojiIcon: "🎼")
musicTool.onGraphicTouched = musicalGraphic(graphic:)
scene.tools.append(musicTool)