用 Swift 打造跳舞機器人 BoogieBot

目的: 學習使用別人寫的 function。

題目來源:
Intro to App Development with Swift 裡 Lesson 7: BoogieBot 的 07_BoogieBot.playground 的 page 10。

學習使用機器人 BoogieBot 提供的 API,控制它跳舞。完成後錄製機器人跳舞的 gif,分享到 Medium 上。

步驟

下載電子書 Intro to App Development with Swift 後,點選以下頁面的 Download Xcode 10 project file 下載書本提供的範例。(大概在第 5 頁)

打開 07_BoogieBot.playground 後,照著檔案裡的說明操作。

點選下方的 Next 按鈕可切換到下一頁。

請切換成 Live View,才能看到可愛的機器人 BoogieBot。

如下圖所示,點選右上角紅色圈圈標示的按鈕,然後點選 Live View。

ps: 舊版的 Xcode 請點選下圖紅色圈圈標示的按鈕。

BoogieBot 的 API 提供以下 function :

  1. 動動手臂
    leftArmUp(), leftArmDown(), rightArmUp(), rightArmDown()
  2. 動動腿
    leftLegUp(), leftLegDown(), rightLegUp(), rightLegDown()

3. 擺臀。
shakeItLeft(), shakeItRight(), shakeItCenter()

4. 跳
jumpUp(), jumpDown()

5. 變色 !
fabulize(), defabulize()

6. 設定標題和副標題。
setBotTitle(“My Awesome Dance”), setBotSubtitle(“By The Boogiemaster”)

練習: 請切換到 playground 的 page 10 Boogie Workshop 寫程式。

彼得潘的 Swift iOS App 開發教室

學習 Swift iOS App 開發的學生作品集

彼得潘的 iOS App Neverland

Written by

彼得潘的 Swift 程式設計入門,App程式設計入門作者,彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,http://apppeterpan.strikingly.com

彼得潘的 Swift iOS App 開發教室

學習 Swift iOS App 開發的學生作品集

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade