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.
核心思路与实现步骤: 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.
动手验证与进阶练习
点击绿旗前先预测运行结果,运行后对比变量与坐标变化,快速掌握原理。
本指南仅供学习参考。Scratch 界面与使用条款可能会随版本更新而变化,请同时参考 Scratch 官方网站说明。