The Haunted House game features an ending where you use camera flashes to fight a monster.
Animations
To start, I personally designed and animated the sprites for the monster. I also set the values for triggering transitions between animations.
When the player did not trigger the monsters collider, it would move towards the player’s position at a steady pace. Once a collision happens, the monsters attack animation is triggered and a light appears. This is joined by a camera shaking animation.
All corresponding lights used by the player and the monster within the scene are always attached to them. They are just enabled and disabled on the codes command along with a custom collision shape.
If the monster is within the players light collision or vice versa, health will be deducted from the attacked entity.
Health, Ammo, and UI
The player has a script attached that tracks various values important for the viewer. Each of these can be seen as visuals at the top of the screen. A sliding bar was placed underneath the hearts to keep them filled until damage was taken. They would incrementally decreased with each attack. A similar effect happened with the cameras. When the player triggered a flash, the bar would go down as well. The value storing the sliders value was also used to create limits in the game. If health was 0, the game would end and if there were no more camera flashes, the player couldn’t attack the enemy.