Same Sprite Multiple Containers

0 favourites
  • 3 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hey,

    I have a bunch of enemy types that I want to share the same health and shield meter sprites.

    As I can't add the same sprite to each enemy's container I was wondering if there was a way I could achieve something similar without having to have a bunch of different health bar sprites? If I have to have a specific life bar sprite or shield sprite for every enemy my project it going to get a little unmanageable.

    Appreciate any help you guys can give, you already sorted my first problem in record time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • shewhorn - Not sure if this is the best way to do it, but what I've been doing for something similar is to give my enemies a "Healthbar" instance variable, and giving my Healthbars the pin behaviour. Instead of using containers, I just pin the healthbar to the enemy and assign the UID to enemies "Healthbar" variable. Then it's just a matter of picking your Healthbar object by UID when you need to do anything with it.

    It obviously takes a little more manual work than containers in that you have to create them manually at the same time as your enemy, but it's really only an extra action or two...

  • Awesome, thanks!

    I now have a huge pile of things generic to each enemy that now just handle themselves without having a million different sprites about.

    For anyone else, basically I do:

    On enemyfamily create -> Spawn healthbar

                       Spawn shield

                       Spawn other things

                       Set healthbar ID to enemy.UID

    I then do a for each healthbar with

    enemyfamilypick instance with UID healthbar ID

    Works great and means that my event sheet is a lot smaller as is the list of objects in my project.

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