Problem with multiple enemies?

0 favourites
  • 5 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Basically I have a hit box for my enemy and a separate sprite whose position is set to that box on every tick to represent it (I'm under the impression that it's better practice to do this for collision than to use the actual sprite).

    So, when the enemy is attacked, I switch an instance variable ("dead") from 0 to 1. Then I have a separate event that runs when the dead variable is 1 (true) to animate the enemy exploding and that destroys both the enemy hit box and the sprite that represents it.

    The problem is when I have multiple instances of the enemy, if one of them is attacked, all of them are triggered to die. Do I need separate variables for every instance? How do I do this without creating a big series of events for every single instance of an enemy? Should I not even be using a variable?

    Thanks in advance for any help!

  • If you put the enemy and the hitbox to a container, this could solve everything.

    another option is to pick the right enemy sprite in the event, so the action is not called on all instances of the enemy sprite.

  • Any tutorials on containers? I'm not sure at all what that is. Thanks!

  • I think that you have not seen the event sheet for ghost shooter. Why don't you take a look at it via

    new >template ghost shooter

    you should just remodel what you need from that. Containers are not

    necessary if your doing something simple.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Containers might not be necessary, but learning about them in an easy game is better than not knowing about them when trying to create something harder.

    When working with a hitbox and seperate sprite for the enemy it is easier when the sprite and hitbox are "connected" so when you destroy or hit one the other one is automatically "linked", it makes the picking part, which many construct2 users confused, a little easier.

    Here's the manual entry on containers

    If you put the enemy sprite and the hitbox together in a container, when you say on collision with hitbox, enemy play death animation, only the "linked" enemy will play that animation.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)