Web Title:112 學年度 台南市進學國小資訊組112 學年度 台南市進學國小資訊組

Scratch 進階技巧─紀錄與識別分身編號

在 Scratch 中建立分身,如何紀錄與識別「分身」資訊。有以下兩種方式:

一、使用區域變數:
參考 https://wiki.scratch.mit.edu/wiki/Detecting_Clones 文件,於原本的角色中新增一個「區域變數 id」,遞增該值。
當「建立分身」時,分身內也會擁有自己專屬的「區域變數 id」,而它的數值也在當下複製建立。

分身的建立與執行,示意圖如下:

參考程式:

https://scratch.mit.edu/projects/155206934/

二、使用角色內專屬的屬性

  1. 分身建立的當下,需要給予唯一的識別編號,並且紀錄下來;
  2. 儲存這個識別編號,必須與該分身建立連結,以供後續存取,如屬性。

這個範例使用「音量屬性」來紀錄分身的編號資訊,藉以識別分身的差異。
點一下分身,顯示目前的編號。

這是一個紆迴的技巧,受限於音量屬性只有 0 ~ 100 的承載量。

https://scratch.mit.edu/projects/155206934/

相關連結:https://scratch.mit.edu/projects/155206934/

搜尋

活動剪影秀

  • slider image 1
  • slider image 2
  • slider image 3
  • slider image 4
  • slider image 5
  • slider image 6
  • slider image 7
  • slider image 8
  • slider image 9
  • slider image 10
  • slider image 11
  • slider image 12
  • slider image 13
  • slider image 14

準備全國紫錐花盃反毒機器人競賽