Same Sprite Multiple Containers

Get help using Construct 2

Post » Fri Apr 12, 2013 4:18 pm


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.

Posts: 14
Reputation: 403

Post » Fri Apr 12, 2013 4:29 pm

@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...

rogueNoodle2013-04-12 16:30:52
Posts: 63
Reputation: 3,083

Post » Sat Apr 13, 2013 5:15 pm

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.
Posts: 14
Reputation: 403

Return to How do I....?

Who is online

Users browsing this forum: Artpunk, cococwy522, cotteux, farfetchd83, jojoe, nav, plinkie and 9 guests