快速連結

2022年12月25日

幫文字加入星號來遮罩文字

參考網址:How to mask a String to show only the last 3 characters?

extension String{
      /// 幫文字加入星號來遮罩文字
    /// - Parameters:
    ///   - startIndex: 開始遮罩的位置(含)
    ///   - endIndex: 結束遮罩的位置(不含),請勿超過文字長度,沒有做防呆
    /// - Returns: 遮罩後文字
    func maskToStarredWords(_ startIndex: Int, _ endIndex: Int) -> String{
        return prefix(startIndex) + String(repeating: "*", count: Swift.min(endIndex - startIndex + 1, count)) + suffix(count - endIndex - 1)
    }
}

2022年2月10日

使用EventHandler在CocosCreator面板上拉取node函式

紅框圈起來的就是本次文章重點!
這次的範例是Animation自動播放,然後取得clip時間來呼叫結束函式。
當然也可以進入動畫編輯器,插入事件來呼叫結束函式。