# Scratch 實作解法：How to Add Invincibility Frames (i-Frames) After Damage in Scratch

> 先完成最小可運作版本，確認邏輯正確後再加入美術、音效與關卡變化。 Set an invincible flag to 1 and blink ghost effect for 1 second.

[繁體中文] Learn how to add invincibility frames (i-frames) after damage in Scratch with clean block recipes, testing tips, and related guides.

## 核心觀念與實作步驟: Minimal Working Block Recipe

先完成最小可運作版本，確認邏輯正確後再加入美術、音效與關卡變化。

Set an invincible flag to 1 and blink ghost effect for 1 second.

Test this minimal version first, then tune numbers like speed, gravity, or timing to match your game feel.

**Add Invincibility Frames (i-Frames) After Damage script**

- if <(invincible) = (0)> then change [HP] by (-1), set [invincible] to (1)
- repeat (5): set ghost to 50 -> wait 0.1 -> set ghost to 0
- set [invincible] to (0)

動手試試看: Prevents instant multi-frame deaths.

## 測試檢查與延伸練習: Debugging Checklist & Next Steps

按下綠旗前先預測結果，並觀察變數與座標數值是否符合預期。

If it behaves unexpectedly, verify initial variable resets on the green flag and check that continuous checks sit inside a forever loop.

- [All 120 Scratch How-To Recipes](/zh-tw/howto/): Return to the reverse lookup index.

## 測試檢查與延伸練習

按下綠旗前先預測結果，並觀察變數與座標數值是否符合預期。

- [返回分類總覽](/zh-tw/howto/): Scratch 目的反查辭典
- [關於 Scratch大全（編輯方針與品質標準）](/zh-tw/about/): 認識 Scratch大全 如何在10種語言中提供系統化的 Scratch 積木辭典、教科書、實作專案與開放教學資料。

更新日期: 2026-11-23
作者: [鈴木孝昌 (Takamasa Suzuki)](https://scratch.gmnavi.jp/about/author/)
Japanese Edition: https://scratch.gmnavi.jp/howto/invincible-frame/

[Scratch大全 (繁體中文)](https://scratch.gmnavi.jp/zh-tw/)
