let blu = Graphic(image: #imageLiteral(resourceName: "Blu1@2x.png"))
let theOrigin = Point(x: 0, y: 0)
scene.place(blu, at: theOrigin)
func soundGraphic(graphic: Graphic) {
if graphic == blu {
playSound(.bluDance, volume: 75)
}
if graphic.text == "🍐" {
playSound(.electricity)
} else if graphic.text == "🍊" {
playSound(.phone)
} else if graphic.text == "🍋" {
playSound(.knock)
}
}
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 soundTool = Tool(name: "Sound", emojiIcon: "📣")
soundTool.onGraphicTouched = soundGraphic(graphic:)
scene.tools.append(soundTool)