I finally finished the last spell effect for MatchCraft! I still have a bit of work left for the UI as well as sounds but this baby is almost ready to release. The last spell, Water Spray was a challenge. I thought it would be one of the easiest but that wasn’t the case.
Most of the spell effects operate on a timer. This generally works well but since this spell effect travels across the screen and can have a weird origin, such as the lower right corner of the window, the effect was harder to pull off. Using a timer alone wouldn’t work, as the gems would destroy at weird moments in the animation. Sometimes they would blow up too early, sometimes too late.
I fixed this by calculating where the leading edge of the water spray would be based on the current frame of the animation and destroying the gem nearest that point, which is how the effect would work in real life anyhow!