Post #12: Dodge the Creeps, Part 3
Today, we resume our journey through the Dodge the Creeps tutorial. In our last post on this (Dodge the Creeps, Part 2), we added the player animation and movement.
The next step is to add the enemies that the player has to dodge. This involves creating the enemy and adding signals to manage the collision between the player and enemy, as well as prepping for what happens when the player is hit (we eventually need to add code that removes the player, shows "game over", and allow the player to restart the game).
Here are two takeaways as I go through this part of the tutorial:
- When the player is hit, we want to disable the player's collision so that the "hit" isn't registered multiple times. To do this, we use
$CollisionShape2D.set_deferred("disabled", true). We need to useset_deferredbecause errors can occur if we try to disable a collision shape when the engine is doing collision processing. - When the enemies wander around and eventually reach the edge of the screen, we call
queue_free(). This function queues the node to be deleted.
Not done yet, but I'm working on it!
