All of the assets required can be downloaded here.
The sprites are in the Traps --> FireÂ
Add the Spiked Ball folder to the FileSystem
Create any level you like.
You may copy my level layout.
We will place one Strawberry strategicallyÂ
Also, we will create a scene for a Fire Pot
Create a new scene with Area2D as root
Add a CollisionShape2D with New RectangleShape2D
An an AnimatedSprite2D with Sprite Frames
Rename the default animation to "off"
use the Off.png as the frame
Add a new animation called on
Import the 3 frames from On.png
Add a new animation called trigger
Import the 4 frames from Hit.png
In the AnimatedSprite2D node
Now select the CollisionShape2D node
Add a StaticBody2D node as a child of Fire
Add a CollisionShape2D as a child of StaticBody2D
Add a New RectangleShape2D
Fit it around the fire pot
Attach a New script to the Fire node
add a reference variable to the AnimatedSprite2D
Connect the body entered signal
if the body is the player
play the trigger animation
if the on animation is playing
call the hurt function of the player
Select the AnimatedSprite2D node
Connect the animation finished signal
if the animation name is trigger
To improve gameplay when the player is hurt we will make them invincible for a second before they can be hurt again
Add an invincibility duration variable
Add an is_invincible variable
if the player is invincible or dead
start the invincibility timer
reset invincibilty on timeout